summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2006-07-03 13:14:01 +0000
committerJim Meyering <jim@meyering.net>2006-07-03 13:14:01 +0000
commit2741ffb8b4cdf076c5e973931c9afb474f1c5306 (patch)
tree8450a8763a743e5b94f1d5630196e94a8d3efdb5
parentae87c86b4a9a5149d431f831653573ebc6fb15f2 (diff)
downloadcoreutils-2741ffb8b4cdf076c5e973931c9afb474f1c5306.tar.xz
Fix two small leaks.
* src/remove.c (AD_stack_clear): New function. (rm_1): Use it. (AD_pop_and_chdir): Free *prev_dir just before longjmp.
-rw-r--r--ChangeLog5
-rw-r--r--src/remove.c12
2 files changed, 17 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index c263aeeaa..183a8d155 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2006-07-03 Jim Meyering <jim@meyering.net>
+ Fix two small leaks.
+ * src/remove.c (AD_stack_clear): New function.
+ (rm_1): Use it.
+ (AD_pop_and_chdir): Free *prev_dir just before longjmp.
+
* tests/Makefile.am, tests/*/Makefile.am: (TESTS_ENVIRONMENT):
Add $VG_PATH_PREFIX as a prefix to $PATH
diff --git a/src/remove.c b/src/remove.c
index a219955bc..bc0b92b7b 100644
--- a/src/remove.c
+++ b/src/remove.c
@@ -345,6 +345,15 @@ AD_stack_pop (Dirstack_state *ds)
obstack_blank (&ds->Active_dir, -(int) sizeof (struct AD_ent));
}
+static void
+AD_stack_clear (Dirstack_state *ds)
+{
+ while (0 < AD_stack_height (ds))
+ {
+ AD_stack_pop (ds);
+ }
+}
+
static Dirstack_state *
ds_init (void)
{
@@ -469,6 +478,7 @@ AD_pop_and_chdir (DIR **dirp, Dirstack_state *ds, char **prev_dir)
close (fd);
next_cmdline_arg:;
+ free (*prev_dir);
longjmp (ds->current_arg_jumpbuf, 1);
}
}
@@ -1375,6 +1385,8 @@ rm_1 (Dirstack_state *ds, char const *filename,
status = RM_ERROR;
else
status = remove_dir (fd_cwd, ds, filename, x, cwd_errno);
+
+ AD_stack_clear (ds);
}
ds_clear (ds);