Bug 1509849 - Treat an empty string as non-wellformed when creating Locale, but don't throw an assertion. r=gandalf
authorJonathan Kew <jkew@mozilla.com>
Mon, 26 Nov 2018 19:25:11 +0000
changeset 507268 e8eaf7539ccb57dece538a004d9f22e932f8e244
parent 507267 23e952aa9c8f394d8ca4818bcac4c7e8f8784a64
child 507269 2fdce5544015e6b150cfdad4921eab0dbd11be93
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgandalf
bugs1509849
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1509849 - Treat an empty string as non-wellformed when creating Locale, but don't throw an assertion. r=gandalf
intl/locale/MozLocale.cpp
--- a/intl/locale/MozLocale.cpp
+++ b/intl/locale/MozLocale.cpp
@@ -13,25 +13,23 @@
 using namespace mozilla::intl;
 
 /**
  * Note: The file name is `MozLocale` to avoid compilation problems on case-insensitive
  * Windows. The class name is `Locale`.
  */
 Locale::Locale(const nsACString& aLocale)
 {
-  MOZ_ASSERT(!aLocale.IsEmpty(), "Locale string cannot be empty");
-
-  int32_t position = 0;
-
-  if (!IsASCII(aLocale)) {
+  if (aLocale.IsEmpty() || !IsASCII(aLocale)) {
     mIsWellFormed = false;
     return;
   }
 
+  int32_t position = 0;
+
   nsAutoCString normLocale(aLocale);
   normLocale.ReplaceChar('_', '-');
 
   /**
    * BCP47 language tag:
    *
    * langtag = language            2*3ALPHA
    *           ["-" extlang]       3ALPHA *2("-" 3ALPHA)