summaryrefslogtreecommitdiff
path: root/posix
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2006-10-02 19:02:41 +0000
committerJakub Jelinek <jakub@redhat.com>2006-10-02 19:02:41 +0000
commit16d1b47b4f3f9ae13535ea7a2c02bd207c069d5c (patch)
tree975d67b5fe35279f3f4834b4c345b18b927a57b9 /posix
parentaf47bc499af76c844b28d9ca912ed81f2a353708 (diff)
Updated to fedora-glibc-20061002T1858cvs/fedora-glibc-2_5-2cvs/fedora-2_5-base
Diffstat (limited to 'posix')
-rw-r--r--posix/glob.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/posix/glob.c b/posix/glob.c
index 630d54063a..0079a15a92 100644
--- a/posix/glob.c
+++ b/posix/glob.c
@@ -1287,8 +1287,15 @@ glob_in_dir (const char *pattern, const char *directory, int flags,
for (size_t i = 0; i < cur; ++i)
free (names->name[i]);
names = names->next;
+ /* NB: we will not leak memory here if we exit without
+ freeing the current block assigned to OLD. At least
+ the very first block is always allocated on the stack
+ and this is the block assigned to OLD here. */
if (names == NULL)
- break;
+ {
+ assert (old == &init_names);
+ break;
+ }
cur = names->count;
if (old == names_alloca)
names_alloca = names;
@@ -1306,8 +1313,15 @@ glob_in_dir (const char *pattern, const char *directory, int flags,
new_gl_pathv[pglob->gl_offs + pglob->gl_pathc++]
= names->name[i];
names = names->next;
+ /* NB: we will not leak memory here if we exit without
+ freeing the current block assigned to OLD. At least
+ the very first block is always allocated on the stack
+ and this is the block assigned to OLD here. */
if (names == NULL)
- break;
+ {
+ assert (old == &init_names);
+ break;
+ }
cur = names->count;
if (old == names_alloca)
names_alloca = names;