]> CyberLeo.Net >> Repos - FreeBSD/stable/8.git/commit
MFC r243758 (marcel):
authordelphij <delphij@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Tue, 5 Feb 2013 09:50:33 +0000 (09:50 +0000)
committerdelphij <delphij@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Tue, 5 Feb 2013 09:50:33 +0000 (09:50 +0000)
commit8ad14e3fd8b0c83c5360b6cf4d6481231a046d6e
treec05f404e36fcdc82f48d810a911e55e892a1b0fa
parente31a0fe305d76a6d2afa21eb22a94c6884018270
MFC r243758 (marcel):

In globextend() when the pathv vector cannot be (re-)allocated, don't
free and clear the gl_pathv pointer in the glob_t structure. Such
breaks the invariant of the glob_t structure, as stated in the comment
right in front of the globextend() function. If gl_pathv was non-NULL,
then gl_pathc was > 0. Making gl_pathv a NULL pointer without also
setting gl_pathc to 0 is wrong.

Since we otherwise don't free the memory associated with a glob_t in
error cases, it's unlikely that this change will cause a memory leak
that wasn't already there to begin with. Callers of glob(3) must
call globfree(3) irrespective of whether glob(3) returned an error
or not.

MFC r243759 (marcel):

In globextend(), take advantage of the fact that realloc(NULL, size) is
equivalent to malloc(size). This eliminates the conditional expression
used for calling either realloc() or malloc() when realloc() will do
all the time.

git-svn-id: svn://svn.freebsd.org/base/stable/8@246356 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
lib/libc/gen/glob.c