Bug 1373763: Extend scope for local variable in uprv_convertToPosix. r=dmajor
authorAndré Bargull <andre.bargull@gmail.com>
Thu, 29 Jun 2017 10:22:07 -0700
changeset 368077 3a8ffdd054153b66b5fa519214ac2429743b803d
parent 368076 afad368bc897f3463e9d654ae7829cd17fd8ce3a
child 368078 ed18b5a361f9ee5f0656eb98e2fce54adbd93373
push id32157
push userkwierso@gmail.com
push dateTue, 11 Jul 2017 01:43:14 +0000
treeherdermozilla-central@0e41d07a703f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdmajor
bugs1373763
milestone56.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 1373763: Extend scope for local variable in uprv_convertToPosix. r=dmajor
intl/icu-patches/bug-1373763-convertToPosix-stack-value-out-of-scope.diff
intl/icu/source/common/locmap.cpp
intl/update-icu.sh
new file mode 100644
--- /dev/null
+++ b/intl/icu-patches/bug-1373763-convertToPosix-stack-value-out-of-scope.diff
@@ -0,0 +1,34 @@
+Move the stack allocated buffer to the top-level, so its value can be accessed after the if-statement.
+
+https://ssl.icu-project.org/trac/ticket/13263
+
+diff --git a/intl/icu/source/common/locmap.cpp b/intl/icu/source/common/locmap.cpp
+--- a/intl/icu/source/common/locmap.cpp
++++ b/intl/icu/source/common/locmap.cpp
+@@ -1028,24 +1028,25 @@ U_CAPI int32_t
+ uprv_convertToPosix(uint32_t hostid, char *posixID, int32_t posixIDCapacity, UErrorCode* status)
+ {
+     uint16_t langID;
+     uint32_t localeIndex;
+     UBool bLookup = TRUE;
+     const char *pPosixID = NULL;
+ 
+ #ifdef USE_WINDOWS_LCID_MAPPING_API
++    char locName[LOCALE_NAME_MAX_LENGTH] = {};      // ICU name can't be longer than Windows name
++
+     // Note: Windows primary lang ID 0x92 in LCID is used for Central Kurdish and
+     // GetLocaleInfo() maps such LCID to "ku". However, CLDR uses "ku" for
+     // Northern Kurdish and "ckb" for Central Kurdish. For this reason, we cannot
+     // use the Windows API to resolve locale ID for this specific case.
+     if ((hostid & 0x3FF) != 0x92) {
+         int32_t tmpLen = 0;
+         UChar windowsLocaleName[LOCALE_NAME_MAX_LENGTH];  // ULOC_FULLNAME_CAPACITY > LOCALE_NAME_MAX_LENGTH
+-        char locName[LOCALE_NAME_MAX_LENGTH];             // ICU name can't be longer than Windows name
+ 
+         // Note: LOCALE_ALLOW_NEUTRAL_NAMES was enabled in Windows7+, prior versions did not handle neutral (no-region) locale names.
+         tmpLen = LCIDToLocaleName(hostid, (PWSTR)windowsLocaleName, UPRV_LENGTHOF(windowsLocaleName), LOCALE_ALLOW_NEUTRAL_NAMES);
+         if (tmpLen > 1) {
+             int32_t i = 0;
+             // Only need to look up in table if have _, eg for de-de_phoneb type alternate sort.
+             bLookup = FALSE;
+             for (i = 0; i < UPRV_LENGTHOF(locName); i++)
--- a/intl/icu/source/common/locmap.cpp
+++ b/intl/icu/source/common/locmap.cpp
@@ -1028,24 +1028,25 @@ U_CAPI int32_t
 uprv_convertToPosix(uint32_t hostid, char *posixID, int32_t posixIDCapacity, UErrorCode* status)
 {
     uint16_t langID;
     uint32_t localeIndex;
     UBool bLookup = TRUE;
     const char *pPosixID = NULL;
 
 #ifdef USE_WINDOWS_LCID_MAPPING_API
+    char locName[LOCALE_NAME_MAX_LENGTH] = {};      // ICU name can't be longer than Windows name
+
     // Note: Windows primary lang ID 0x92 in LCID is used for Central Kurdish and
     // GetLocaleInfo() maps such LCID to "ku". However, CLDR uses "ku" for
     // Northern Kurdish and "ckb" for Central Kurdish. For this reason, we cannot
     // use the Windows API to resolve locale ID for this specific case.
     if ((hostid & 0x3FF) != 0x92) {
         int32_t tmpLen = 0;
         UChar windowsLocaleName[LOCALE_NAME_MAX_LENGTH];  // ULOC_FULLNAME_CAPACITY > LOCALE_NAME_MAX_LENGTH
-        char locName[LOCALE_NAME_MAX_LENGTH];             // ICU name can't be longer than Windows name
 
         // Note: LOCALE_ALLOW_NEUTRAL_NAMES was enabled in Windows7+, prior versions did not handle neutral (no-region) locale names.
         tmpLen = LCIDToLocaleName(hostid, (PWSTR)windowsLocaleName, UPRV_LENGTHOF(windowsLocaleName), LOCALE_ALLOW_NEUTRAL_NAMES);
         if (tmpLen > 1) {
             int32_t i = 0;
             // Only need to look up in table if have _, eg for de-de_phoneb type alternate sort.
             bLookup = FALSE;
             for (i = 0; i < UPRV_LENGTHOF(locName); i++)
--- a/intl/update-icu.sh
+++ b/intl/update-icu.sh
@@ -66,16 +66,17 @@ find ${icu_dir}/source/data/zone \
 svn info $1 | grep -v '^Revision: [[:digit:]]\+$' > ${icu_dir}/SVN-INFO
 
 for patch in \
  bug-915735 \
  suppress-warnings.diff \
  bug-1172609-timezone-recreateDefault.diff \
  bug-1198952-workaround-make-3.82-bug.diff \
  u_setMemoryFunctions-callconvention-anachronism-msvc.diff \
+ bug-1373763-convertToPosix-stack-value-out-of-scope.diff \
 ; do
   echo "Applying local patch $patch"
   patch -d ${icu_dir}/../../ -p1 --no-backup-if-mismatch < ${icu_dir}/../icu-patches/$patch
 done
 
 topsrcdir=`dirname $0`/../
 python ${topsrcdir}/js/src/tests/ecma_6/String/make-normalize-generateddata-input.py $topsrcdir