Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 85450d1

Browse files
author
Marina Polyakova
committed
ICU: fix the use of char2wchar_ascii
Pass the fromlen argument as the length of the input string not counting the null character because it will be added to the output string separatly. Otherwise you can add it twice and a memory error may occur.
1 parent 4389fc4 commit 85450d1

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/port/chklocale.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -959,12 +959,12 @@ check_icu_winlocale(const char *winlocale)
959959
}
960960
else
961961
{
962-
size_t locale_size = strlen(winlocale) + 1;
963-
size_t locale_wsize = locale_size * sizeof(wchar_t);
964-
wchar_t *wlocale = (wchar_t*) ALLOC(locale_wsize);
962+
size_t locale_len = strlen(winlocale);
963+
wchar_t *wlocale = (wchar_t*) ALLOC(
964+
(locale_len + 1) * sizeof(wchar_t));
965965
/* Locale names use only ASCII */
966-
size_t locale_wlen = char2wchar_ascii(wlocale, locale_wsize,
967-
winlocale, locale_size);
966+
size_t locale_wlen = char2wchar_ascii(wlocale, locale_len + 1,
967+
winlocale, locale_len);
968968
if (locale_wlen == -1)
969969
{
970970
/* there's an error */

0 commit comments

Comments
 (0)