From: Jim Meyering Date: Thu, 21 Oct 2004 10:37:18 +0000 (+0000) Subject: Correct my patch of 2004-10-18. X-Git-Tag: v5.3.0~509 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2469a229d50e549d149de43bfac3e1bf13b4b6ee;p=thirdparty%2Fcoreutils.git Correct my patch of 2004-10-18. (rm): Destroy the saved_cwd here (via cwd_state), if necessary, not in remove_dir. Otherwise, removing multiple `.'-relative nonempty directories no longer worked. --- diff --git a/src/remove.c b/src/remove.c index 6ff47c97c0..8f381ae5d1 100644 --- a/src/remove.c +++ b/src/remove.c @@ -1151,10 +1151,7 @@ remove_dir (Dirstack_state *ds, char const *dir, struct cwd_state **cwd_state, free (empty_dir); if (AD_stack_height (ds) == 1) - { - free_cwd (&AD_stack_top(ds)->u.saved_cwd); - break; - } + break; } } @@ -1235,6 +1232,9 @@ rm (size_t n_files, char const *const *file, struct rm_options const *x) ds_free (ds); + if (cwd_state && cwd_state->saved_errno == 0) + free_cwd (&cwd_state->saved_cwd); + free (cwd_state); return status;