diff options
author | Jim Meyering <jim@meyering.net> | 2006-07-03 13:14:01 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2006-07-03 13:14:01 +0000 |
commit | 2741ffb8b4cdf076c5e973931c9afb474f1c5306 (patch) | |
tree | 8450a8763a743e5b94f1d5630196e94a8d3efdb5 /src | |
parent | ae87c86b4a9a5149d431f831653573ebc6fb15f2 (diff) | |
download | coreutils-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.
Diffstat (limited to 'src')
-rw-r--r-- | src/remove.c | 12 |
1 files changed, 12 insertions, 0 deletions
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); |