msvcrt: Don't depend on how __lc_time_data was allocated in _Gettnames.

Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Piotr Caban 2019-12-04 15:30:38 +01:00 committed by Alexandre Julliard
parent 9571b36241
commit 1b6eee3069
1 changed files with 5 additions and 3 deletions

View File

@ -604,7 +604,7 @@ MSVCRT_wchar_t* CDECL _W_Getmonths(void)
void* CDECL _Gettnames(void)
{
MSVCRT___lc_time_data *ret, *cur = get_locinfo()->lc_time_curr;
unsigned int i, size = sizeof(MSVCRT___lc_time_data);
unsigned int i, len, size = sizeof(MSVCRT___lc_time_data);
TRACE("\n");
@ -614,12 +614,14 @@ void* CDECL _Gettnames(void)
ret = MSVCRT_malloc(size);
if(!ret)
return NULL;
memcpy(ret, cur, size);
memcpy(ret, cur, sizeof(*ret));
size = 0;
for(i=0; i<ARRAY_SIZE(cur->str.str); i++) {
len = strlen(cur->str.str[i])+1;
memcpy(&ret->data[size], cur->str.str[i], len);
ret->str.str[i] = &ret->data[size];
size += strlen(&ret->data[size])+1;
size += len;
}
return ret;