]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Rework VG_(memmove) in the case where the destination address is greater
authorTom Hughes <tom@compton.nu>
Tue, 3 Nov 2009 21:14:31 +0000 (21:14 +0000)
committerTom Hughes <tom@compton.nu>
Tue, 3 Nov 2009 21:14:31 +0000 (21:14 +0000)
that the source address to use the same logic as the mc_replace_strmem.c
version so that underflow is avoided. Fixes #211008.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10925

coregrind/m_libcbase.c

index 3614b9202bdc11fd89d4aa4a8a8a335ca12cf3a4..13e98bc5316dbc4bff0f20bc93b0c9f932441d75 100644 (file)
@@ -437,8 +437,8 @@ void* VG_(memmove)(void *dest, const void *src, SizeT sz)
       }
    }
    else if (dest > src) {
-      for (i = sz - 1; i >= 0; i--) {
-         ((UChar*)dest)[i] = ((UChar*)src)[i];
+      for (i = 0; i < sz; i++) {
+         ((UChar*)dest)[sz-i-1] = ((UChar*)src)[sz-i-1];
       }
    }
    return dest;