Felix Hädicke : msvcrt: Use memmove() instead of memcpy() puts_clbk_str().

Alexandre Julliard julliard at winehq.org
Mon Apr 20 15:01:48 CDT 2020


Module: wine
Branch: oldstable
Commit: d20c3d3f1a2d9e5a78479396160f57cf180350a9
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=d20c3d3f1a2d9e5a78479396160f57cf180350a9

Author: Felix Hädicke <felixhaedicke at web.de>
Date:   Thu Oct 10 23:39:35 2019 +0200

msvcrt: Use memmove() instead of memcpy() puts_clbk_str().

memcpy() must not be used here, because results are undefined if the
memory areas overlap. This can cause problems, particularly if
particular compiler optimisations are enabled.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47918
Signed-off-by: Felix Hädicke <felixhaedicke at web.de>
Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit 90e520b418dcedae6fbfdd56b791ba50652f2ee6)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>

---

 dlls/msvcrt/printf.h | 4 ++--
 dlls/msvcrt/wcs.c    | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/dlls/msvcrt/printf.h b/dlls/msvcrt/printf.h
index 077dafa550..f9adf7521e 100644
--- a/dlls/msvcrt/printf.h
+++ b/dlls/msvcrt/printf.h
@@ -52,13 +52,13 @@ static int FUNC_NAME(puts_clbk_str)(void *ctx, int len, const APICHAR *str)
         return len;
 
     if(out->len < len) {
-        memcpy(out->buf, str, out->len*sizeof(APICHAR));
+        memmove(out->buf, str, out->len*sizeof(APICHAR));
         out->buf += out->len;
         out->len = 0;
         return -1;
     }
 
-    memcpy(out->buf, str, len*sizeof(APICHAR));
+    memmove(out->buf, str, len*sizeof(APICHAR));
     out->buf += len;
     out->len -= len;
     return len;
diff --git a/dlls/msvcrt/wcs.c b/dlls/msvcrt/wcs.c
index b352bf7a88..ebb3dd7119 100644
--- a/dlls/msvcrt/wcs.c
+++ b/dlls/msvcrt/wcs.c
@@ -781,13 +781,13 @@ static int puts_clbk_str_c99_a(void *ctx, int len, const char *str)
         return len;
 
     if(out->len < len) {
-        memcpy(out->buf, str, out->len);
+        memmove(out->buf, str, out->len);
         out->buf += out->len;
         out->len = 0;
         return len;
     }
 
-    memcpy(out->buf, str, len);
+    memmove(out->buf, str, len);
     out->buf += len;
     out->len -= len;
     return len;




More information about the wine-cvs mailing list