[sane-devel] Garbage after device names?

Diego Zuccato diego@otello.alma.unibo.it
Sat, 26 Oct 2002 10:33:52 +0000


Henning Meier-Geinitz wrote:

>   str = malloc (16 + 1);
>   memset (str, 0, sizeof (str));
malloc+memset => calloc
But:
   str[16]=0;
should be enough. No need to zero-out memory you're going to overwrite
immediatly.

> The memset won't work because sizeof (str) is always 4 (on 32 bit
> platforms). And if ibug doesn't contain any zeros --> bang.
Exactly. And it shouldn't contain it, IIUC. Shouldn't it be space-padded
to 16 chars?

Tks,
 Diego.