why this statement will cause analysis error?

Nicholas Sherlock n.sherlock@gmail.com
Thu Oct 21 14:19:00 GMT 2010


On 21/10/2010 11:41 p.m., Lu Fan wrote:
> memcpy(in->sz_a, out.sz_b,sizeof(in->sz_a));
>
> the memcpy will cause analysis error? The tool reports Overrun.

Probably the tool would be happier if you used sizeof(out.sz_b) instead. 
At least that way, if the sizes differed, you would be reading outside a 
buffer instead of writing outside one.

Cheers,
Nicholas Sherlock



More information about the Gcc-help mailing list