From: Tom Hughes Date: Tue, 3 Nov 2009 21:14:31 +0000 (+0000) Subject: Rework VG_(memmove) in the case where the destination address is greater X-Git-Tag: svn/VALGRIND_3_6_0~484 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=574b7707ef6f392051f60b85567f95827a29297f;p=thirdparty%2Fvalgrind.git Rework VG_(memmove) in the case where the destination address is greater 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 --- diff --git a/coregrind/m_libcbase.c b/coregrind/m_libcbase.c index 3614b9202b..13e98bc531 100644 --- a/coregrind/m_libcbase.c +++ b/coregrind/m_libcbase.c @@ -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;