Bug 819825, fix ICE/STUN crash on Android by null-checking setlocale(), r=abr
authorDan Mosedale <dmose@mozilla.org>
Thu, 13 Dec 2012 16:52:52 -0800
changeset 125122 b9a891c0a6e73b6fb9094334de0defb017e840e0
parent 125121 9585e38ed39d87971ff1322259c710f6610510a2
child 125123 7878092679cfc5bb217894bbced986a529f63aa9
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersabr
bugs819825
milestone20.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 819825, fix ICE/STUN crash on Android by null-checking setlocale(), r=abr
media/mtransport/third_party/nICEr/src/util/mbslen.c
--- a/media/mtransport/third_party/nICEr/src/util/mbslen.c
+++ b/media/mtransport/third_party/nICEr/src/util/mbslen.c
@@ -86,19 +86,21 @@ mbslen(const char *s, size_t *ncharsp)
         ABORT(R_NO_MEMORY);
 
     for (i=0; i<strlen(my_locale); i++)
         my_locale[i] = toupper(my_locale[i]);
 
     if (!strstr(my_locale, "UTF-8"))
         ABORT(R_NOT_FOUND);
 #else
-        /* can't count UTF-8 characters with mbrlen if the locale isn't UTF-8 */
-        if (! strcasestr(setlocale(LC_CTYPE, 0), "UTF-8"))
-            ABORT(R_NOT_FOUND);
+    /* can't count UTF-8 characters with mbrlen if the locale isn't UTF-8 */
+    /* null-checking setlocale is required because Android */
+    char *locale = setlocale(LC_CTYPE, 0);
+    if (!locale || !strcasestr(locale, "UTF-8"))
+        ABORT(R_NOT_FOUND);
 #endif
 
 #ifdef DARWIN
     }
 #endif /* DARWIN */
 
     memset(&mbs, 0, sizeof(mbs));
     nchars = 0;