]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
* posix/glob.c (glob_in_dir): Add some comments and asserts to
authorUlrich Drepper <drepper@redhat.com>
Sat, 30 Sep 2006 15:09:35 +0000 (15:09 +0000)
committerUlrich Drepper <drepper@redhat.com>
Sat, 30 Sep 2006 15:09:35 +0000 (15:09 +0000)
explain why there are no leaks.

ChangeLog
libio/bug-wmemstream1.c
libio/tst-wmemstream1.c
libio/tst-wmemstream2.c
libio/wmemstream.c
posix/glob.c

index 22f5067f2d09b7a905661f0153696a4ca7b8e634..d78dffcfa01acf62e8e6fc21abe083345303268c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-09-30  Ulrich Drepper  <drepper@redhat.com>
+
+       * posix/glob.c (glob_in_dir): Add some comments and asserts to
+       explain why there are no leaks.
+
 2006-09-29  Ulrich Drepper  <drepper@redhat.com>
 
        * libio/wmemstream.c: Include <wchar.h>.
index 2190593c9332997b16cbabc7a4f5914820ca9969..22d67f71e93f481a743377e8425480bb8eca6721 100644 (file)
@@ -1,5 +1,6 @@
 #include <stdio.h>
 #include <string.h>
+#include <wchar.h>
 
 
 static int
index 0c59c1adcba837e4b0b9f6658d4a07a22bdff8c2..f8b308bc6cc8d6305d785a9a3ede42b73fdce158 100644 (file)
@@ -1,3 +1,5 @@
+#include <wchar.h>
+
 #define CHAR_T wchar_t
 #define W(o) L##o
 #define OPEN_MEMSTREAM open_wmemstream
index f51a1db20c0317b445c24f364453ffae3a4eeb57..e2442ebfac74a4d609ff002eb89fed57c58dd017 100644 (file)
@@ -1,3 +1,5 @@
+#include <wchar.h>
+
 #define CHAR_T wchar_t
 #define W(o) L##o
 #define OPEN_MEMSTREAM open_wmemstream
index 85ea64991a8453ce1ee19535ae239a2a0fb6f822..577931888debd437a6d1da6c3b0fef6d740b4bb9 100644 (file)
@@ -20,6 +20,7 @@
 #include "strfile.h"
 #include <stdio.h>
 #include <stdlib.h>
+#include <wchar.h>
 
 
 struct _IO_FILE_wmemstream
index 630d54063ae2e09091bc115ad4581d8bc1dc17a9..0079a15a9299564f4ff858f69006e6437372419b 100644 (file)
@@ -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;