Re: msvcrt: dont overlap in strcpy (valgrind)

View: New views
1 Messages — Rating Filter:   Alert me  

Parent Message unknown Re: msvcrt: dont overlap in strcpy (valgrind)

by Vitaliy Margolen-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

André Hentschel wrote:
> here is a case where valgrind claims about "Source and destination overlap in strcpy".
>      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);
> +        }
You should use memmove instead.

Vitaliy.