summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2006-07-03 17:38:20 +0000
committerJim Meyering <jim@meyering.net>2006-07-03 17:38:20 +0000
commita9cf203e2d4a0f94cb2ade11dfbdb903fac70d91 (patch)
treeb8316a804e84001a3cb919a1def3d9323f476cf5
parent1a29d221b8c83adf79cdf4db0a58a23e58202e5f (diff)
downloadcoreutils-a9cf203e2d4a0f94cb2ade11dfbdb903fac70d91.tar.xz
Plug another unusual leak.
(AD_mark_helper): Free malloc'd filename if hash_insert says that string is already in the hash table.
-rw-r--r--ChangeLog4
-rw-r--r--src/remove.c13
2 files changed, 14 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 96391a393..a7168480b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2006-07-03 Jim Meyering <jim@meyering.net>
+ Plug another unusual leak.
+ (AD_mark_helper): Free malloc'd filename if hash_insert says
+ that string is already in the hash table.
+
The dev/inode of the topmost directory in each hierarchy were not
being recorded.
* src/remove.c (remove_cwd_entries): Don't call cycle_check here.
diff --git a/src/remove.c b/src/remove.c
index f85372bb1..5de52df23 100644
--- a/src/remove.c
+++ b/src/remove.c
@@ -497,7 +497,7 @@ AD_pop_and_chdir (DIR **dirp, Dirstack_state *ds, char **prev_dir)
/* Initialize *HT if it is NULL.
Insert FILENAME into HT. */
static void
-AD_mark_helper (Hash_table **ht, char const *filename)
+AD_mark_helper (Hash_table **ht, char *filename)
{
if (*ht == NULL)
{
@@ -506,8 +506,15 @@ AD_mark_helper (Hash_table **ht, char const *filename)
if (*ht == NULL)
xalloc_die ();
}
- if (! hash_insert (*ht, filename))
+ void *ent = hash_insert (*ht, filename);
+ if (ent == NULL)
xalloc_die ();
+ else
+ {
+ if (ent != filename)
+ free (filename);
+ }
+
}
/* Mark FILENAME (in current directory) as unremovable. */
@@ -525,7 +532,7 @@ static void
AD_mark_current_as_unremovable (Dirstack_state *ds)
{
struct AD_ent *top = AD_stack_top (ds);
- char const *curr = top_dir (ds);
+ char *curr = top_dir (ds);
assert (1 < AD_stack_height (ds));