summaryrefslogtreecommitdiff
path: root/src/remove.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2004-10-18 08:59:12 +0000
committerJim Meyering <jim@meyering.net>2004-10-18 08:59:12 +0000
commite302d384211ce08aeb5f6ad0b222ec706bea4468 (patch)
tree3cf92d7c5733b4f7bd311788420e89a923337c49 /src/remove.c
parent35abc478c609f847a7533796d0bafc98808396d5 (diff)
downloadcoreutils-e302d384211ce08aeb5f6ad0b222ec706bea4468.tar.xz
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
Diffstat (limited to 'src/remove.c')
-rw-r--r--src/remove.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/remove.c b/src/remove.c
index c1a3c8f02..6ff47c97c 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;
+ }
}
}