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

Alexandre Julliard julliard at winehq.org
Wed Dec 4 16:13:05 CST 2019


Module: wine
Branch: master
Commit: 1b6eee3069037f291b3986af1ce6ce143ab53659
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=1b6eee3069037f291b3986af1ce6ce143ab53659

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Wed Dec  4 15:30:38 2019 +0100

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

Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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 52052a4502..fdb4436a3d 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; 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;




More information about the wine-cvs mailing list