summaryrefslogtreecommitdiff
path: root/dirent
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1994-09-28 21:23:24 +0000
committerRoland McGrath <roland@gnu.org>1994-09-28 21:23:24 +0000
commit68fe05ccae567730f59a927c74567a5c25cb2a7d (patch)
treec75c1fac0f492c9adae79502204d847719f667f5 /dirent
parent3fc04572939331166311fdff329760b73d4a62a2 (diff)
Free storage on error from readdir.
Diffstat (limited to 'dirent')
-rw-r--r--dirent/scandir.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/dirent/scandir.c b/dirent/scandir.c
index 9b599815ce..6794eadf0d 100644
--- a/dirent/scandir.c
+++ b/dirent/scandir.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992, 1993 Free Software Foundation, Inc.
+/* Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -54,12 +54,8 @@ DEFUN(scandir, (dir, namelist, select, cmp),
if (new == NULL)
{
lose:
- (void) closedir (dp);
- while (i > 0)
- free (v[--i]);
- free (v);
errno = ENOMEM;
- return -1;
+ break;
}
v = new;
}
@@ -75,6 +71,9 @@ DEFUN(scandir, (dir, namelist, select, cmp),
{
save = errno;
(void) closedir (dp);
+ while (i > 0)
+ free (v[--i]);
+ free (v);
errno = save;
return -1;
}