From: Paul Eggert Date: Tue, 1 Feb 2022 03:52:43 +0000 (-0800) Subject: df: fix memory leak X-Git-Tag: v9.1~75 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fb7579768d688a300c4ac76451e1fc7cad59e3e8;p=thirdparty%2Fcoreutils.git df: fix memory leak * src/df.c (devlist_free): Remove. (filter_mount_list): Free all of devlist, instead of merely the entries in devlist_table. --- diff --git a/src/df.c b/src/df.c index 7d32078071..4b2cfb77a6 100644 --- a/src/df.c +++ b/src/df.c @@ -710,12 +710,6 @@ devlist_for_dev (dev_t dev) return found->seen_last; } -static void -devlist_free (void *p) -{ - free (p); -} - /* Filter mount list by skipping duplicate entries. In the case of duplicates - based on the device number - the mount entry with a '/' in its me_devname (i.e., not pseudo name like tmpfs) wins. @@ -736,9 +730,7 @@ filter_mount_list (bool devices_only) mount_list_size++; devlist_table = hash_initialize (mount_list_size, NULL, - devlist_hash, - devlist_compare, - devlist_free); + devlist_hash, devlist_compare, NULL); if (devlist_table == NULL) xalloc_die (); @@ -845,7 +837,9 @@ filter_mount_list (bool devices_only) me = device_list->me; me->me_next = mount_list; mount_list = me; - device_list = device_list->next; + struct devlist *next = device_list->next; + free (device_list); + device_list = next; } hash_free (devlist_table);