msvcrt: Fix uninitialized memory access in wcsrtombs_l implementation (valgrind).
This commit is contained in:
parent
d61e1ffaab
commit
a8c6fda501
@ -313,7 +313,6 @@ static MSVCRT_size_t CDECL MSVCRT_wcsrtombs_l(char *mbstr, const MSVCRT_wchar_t
|
|||||||
MSVCRT_size_t count, MSVCRT__locale_t locale)
|
MSVCRT_size_t count, MSVCRT__locale_t locale)
|
||||||
{
|
{
|
||||||
MSVCRT_pthreadlocinfo locinfo;
|
MSVCRT_pthreadlocinfo locinfo;
|
||||||
char default_char = '\0';
|
|
||||||
MSVCRT_size_t tmp = 0;
|
MSVCRT_size_t tmp = 0;
|
||||||
BOOL used_default;
|
BOOL used_default;
|
||||||
|
|
||||||
@ -322,16 +321,20 @@ static MSVCRT_size_t CDECL MSVCRT_wcsrtombs_l(char *mbstr, const MSVCRT_wchar_t
|
|||||||
else
|
else
|
||||||
locinfo = locale->locinfo;
|
locinfo = locale->locinfo;
|
||||||
|
|
||||||
if(!mbstr)
|
if(!mbstr) {
|
||||||
return WideCharToMultiByte(locinfo->lc_codepage, WC_NO_BEST_FIT_CHARS,
|
tmp = WideCharToMultiByte(locinfo->lc_codepage, WC_NO_BEST_FIT_CHARS,
|
||||||
*wcstr, -1, NULL, 0, &default_char, &used_default)-1;
|
*wcstr, -1, NULL, 0, NULL, &used_default)-1;
|
||||||
|
if(used_default)
|
||||||
|
return -1;
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
while(**wcstr) {
|
while(**wcstr) {
|
||||||
char buf[3];
|
char buf[3];
|
||||||
MSVCRT_size_t i, size;
|
MSVCRT_size_t i, size;
|
||||||
|
|
||||||
size = WideCharToMultiByte(locinfo->lc_codepage, WC_NO_BEST_FIT_CHARS,
|
size = WideCharToMultiByte(locinfo->lc_codepage, WC_NO_BEST_FIT_CHARS,
|
||||||
*wcstr, 1, buf, 3, &default_char, &used_default);
|
*wcstr, 1, buf, 3, NULL, &used_default);
|
||||||
if(used_default)
|
if(used_default)
|
||||||
return -1;
|
return -1;
|
||||||
if(tmp+size > count)
|
if(tmp+size > count)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user