Bug 1339119 - Actually use the locale from macOS instead of throwing it away in OSPreferences::ReadSystemLocales. r=gandalf draft
authorJonathan Kew <jkew@mozilla.com>
Mon, 13 Feb 2017 17:51:13 +0000
changeset 485873 931b7af2ab3e26612ccfc107979b00700534f58d
parent 485872 ef01429775a28b7e8f0c0e6106e11521c414007e
child 485874 8d3a9ace5a9a1a9b1735673f835692c0245f21af
push id45870
push userbmo:kechen@mozilla.com
push dateFri, 17 Feb 2017 09:36:54 +0000
reviewersgandalf
bugs1339119
milestone54.0a1
Bug 1339119 - Actually use the locale from macOS instead of throwing it away in OSPreferences::ReadSystemLocales. r=gandalf
intl/locale/mac/OSPreferences_mac.cpp
--- a/intl/locale/mac/OSPreferences_mac.cpp
+++ b/intl/locale/mac/OSPreferences_mac.cpp
@@ -15,16 +15,17 @@ OSPreferences::ReadSystemLocales(nsTArra
   MOZ_ASSERT(aLocaleList.IsEmpty());
 
   // Get string representation of user's current locale
   CFLocaleRef userLocaleRef = ::CFLocaleCopyCurrent();
   CFStringRef userLocaleStr = ::CFLocaleGetIdentifier(userLocaleRef);
 
   AutoTArray<UniChar, 32> buffer;
   int size = ::CFStringGetLength(userLocaleStr);
+  buffer.SetLength(size);
 
   CFRange range = ::CFRangeMake(0, size);
   ::CFStringGetCharacters(userLocaleStr, range, buffer.Elements());
 
   // Convert the locale string to the format that Mozilla expects
   NS_LossyConvertUTF16toASCII locale(
       reinterpret_cast<const char16_t*>(buffer.Elements()), buffer.Length());