msvcrt: do not overlap in strcpy (valgrind) (try 2)

André Hentschel nerv at dawncrow.de
Fri Oct 30 13:43:14 CDT 2009


here is a case where valgrind claims about "Source and destination overlap in strcpy".
this is a proposal for a safer string moving.
see also http://kegel.com/wine/valgrind/logs/2009-10-26-08.26/vg-msvcrt_printf.txt

try2: use memmove instead like Vitaliy metioned

---
 dlls/msvcrt/math.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c
index 010e1a6..08eaf73 100644
--- a/dlls/msvcrt/math.c
+++ b/dlls/msvcrt/math.c
@@ -856,7 +856,7 @@ char * CDECL _ecvt( double number, int ndigits, int *decpt, int *sign )
     snprintf(data->efcvt_buffer, 80, "%.*le", prec - 1, number);
     /* take the decimal "point away */
     if( prec != 1)
-        strcpy( data->efcvt_buffer + 1, data->efcvt_buffer + 2);
+        memmove( data->efcvt_buffer + 1, data->efcvt_buffer + 2, strlen(data->efcvt_buffer) );
     /* take the exponential "e" out */
     data->efcvt_buffer[ prec] = '\0';
     /* read the exponent */
-- 

Best Regards, André Hentschel



More information about the wine-patches mailing list