From e302d384211ce08aeb5f6ad0b222ec706bea4468 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Mon, 18 Oct 2004 08:59:12 +0000 Subject: [PATCH] Plug a leak that would cause rm or a cross-device mv to fail when operating on too many command-line-specified nonempty directories. (remove_dir): Destroy the `struct saved_cwd' on the top of the stack before returning. This usually closes the file descriptor that was used to return to the original working directory. Reported by Cyril Bouthors in http://article.gmane.org/gmane.comp.gnu.core-utils.bugs/3048 --- src/remove.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/remove.c b/src/remove.c index c1a3c8f026..6ff47c97c0 100644 --- a/src/remove.c +++ b/src/remove.c @@ -1151,7 +1151,10 @@ remove_dir (Dirstack_state *ds, char const *dir, struct cwd_state **cwd_state, free (empty_dir); if (AD_stack_height (ds) == 1) - break; + { + free_cwd (&AD_stack_top(ds)->u.saved_cwd); + break; + } } } -- 2.47.2