msvcrt: dont overlap in strcpy (valgrind)
André Hentschel
nerv at dawncrow.de
Thu Oct 29 13:11:49 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
---
dlls/msvcrt/math.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c
index 010e1a6..bf5194b 100644
--- a/dlls/msvcrt/math.c
+++ b/dlls/msvcrt/math.c
@@ -856,7 +856,10 @@ 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);
+ {
+ char *src = data->efcvt_buffer + 2, *dest = data->efcvt_buffer + 1;
+ while ((*dest++=*src++) != 0);
+ }
/* 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