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

Alexandre Julliard julliard at winehq.org
Wed Oct 16 16:59:29 CDT 2019


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

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>

---

 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 a0d75401c4..346fb5ac5d 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 f84963ce2e..3e5bb512ff 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