]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
Plug a leak that would cause rm or a cross-device mv to fail when
authorJim Meyering <jim@meyering.net>
Mon, 18 Oct 2004 08:59:12 +0000 (08:59 +0000)
committerJim Meyering <jim@meyering.net>
Mon, 18 Oct 2004 08:59:12 +0000 (08:59 +0000)
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

index c1a3c8f0264d5f58e0f22a25808ff2e712fb373a..6ff47c97c07aa4c5ca746cfa1e1e678cfde294bc 100644 (file)
@@ -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;
+         }
       }
     }