[PATCH] avoid malloc(0) in getdents

Dmitry V. Levin ldv at altlinux.org
Wed Oct 7 23:32:39 UTC 2009


On Wed, Oct 07, 2009 at 05:25:01AM -0400, Mike Frysinger wrote:
> When getdents finishes processing, it returns 0.  Strace uses this to then
> try and do malloc(0), but on some systems this will always return NULL.
> Since the code won't read the pointer in question if len is 0, then don't
> abort on the malloc(0) == NULL case.

When len == 0, the buffer allocated by malloc(0) is not used anyway, so
there are no need to malloc(0) here even on regular systems where
malloc(0) allocates memory, right?


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20091008/a9dc69fe/attachment.bin>


More information about the Strace-devel mailing list