(fts_build): Free `head' before returning NULL, in two places,
authorJim Meyering <jim@meyering.net>
Fri, 14 Apr 2006 16:26:15 +0000 (16:26 +0000)
committerJim Meyering <jim@meyering.net>
Fri, 14 Apr 2006 16:26:15 +0000 (16:26 +0000)
to avoid leaks.  Patch from glibc.

lib/fts.c

index eede736..e9896cd 100644 (file)
--- a/lib/fts.c
+++ b/lib/fts.c
@@ -1010,6 +1010,7 @@ mem1:                             saved_errno = errno;
             fts_safe_changedir(sp, cur->fts_parent, -1, ".."))) {
                cur->fts_info = FTS_ERR;
                SET(FTS_STOP);
+               fts_lfree(head);
                return (NULL);
        }
 
@@ -1017,6 +1018,7 @@ mem1:                             saved_errno = errno;
        if (!nitems) {
                if (type == BREAD)
                        cur->fts_info = FTS_DP;
+               fts_lfree(head);
                return (NULL);
        }