From 1b6eee3069037f291b3986af1ce6ce143ab53659 Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Wed, 4 Dec 2019 15:30:38 +0100 Subject: [PATCH] msvcrt: Don't depend on how __lc_time_data was allocated in _Gettnames. Signed-off-by: Piotr Caban Signed-off-by: Alexandre Julliard --- dlls/msvcrt/locale.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dlls/msvcrt/locale.c b/dlls/msvcrt/locale.c index 52052a4502a..fdb4436a3d1 100644 --- a/dlls/msvcrt/locale.c +++ b/dlls/msvcrt/locale.c @@ -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; istr.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;