[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: di-set: Fix memory leak
From: |
Bernhard Voelker |
Subject: |
Re: di-set: Fix memory leak |
Date: |
Thu, 18 Apr 2019 23:15:59 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 |
On 3/10/19 2:20 PM, Bruno Haible wrote:
> 2019-03-10 Bruno Haible <address@hidden>
>
> di-set: Fix memory leak.
> * lib/di-set.c (di_set_free): Free the ino_map through ino_map_free(),
> not free().
>
> diff --git a/lib/di-set.c b/lib/di-set.c
> index e8f69db..2c0601e 100644
> --- a/lib/di-set.c
> +++ b/lib/di-set.c
> @@ -136,7 +136,7 @@ void
> di_set_free (struct di_set *dis)
> {
> hash_free (dis->dev_map);
> - free (dis->ino_map);
> + ino_map_free (dis->ino_map);
> free (dis->probe);
> free (dis);
> }
This commit (3703dbbe88dd) makes coreutils' du(1) crash.
Reproducer:
---------------------------------------------------------
#!/bin/sh
set -x
git clone --depth=1 git://git.sv.gnu.org/gnulib.git \
&& cd gnulib \
&& rm -rf /tmp/testdir/ \
&& ./gnulib-tool --create-testdir --with-tests --dir=/tmp/testdir di-set \
&& cd /tmp/testdir \
&& ./configure --quiet \
&& make \
&& patch -p0 --fuzz=0 <<<'\
--- gltests/test-di-set.c.ORIG 2019-04-10 08:23:09.663882510 +0200
+++ gltests/test-di-set.c 2019-04-18 22:27:57.778264454 +0200
@@ -27,6 +27,9 @@
{
struct di_set *dis = di_set_alloc ();
ASSERT (dis);
+ di_set_free (dis);
+ dis = di_set_alloc ();
+ ASSERT (dis);
ASSERT (di_set_lookup (dis, 2, 5) == 0); /* initial lookup fails */
ASSERT (di_set_insert (dis, 2, 5) == 1); /* first insertion succeeds */
' \
&& make check
---------------------------------------------------------
The attached allows for 'ino-map' to free on NULL.
Have a nice day,
Berny
0001-ino-map-allow-free-on-NULL.patch
Description: Text Data
- Re: di-set: Fix memory leak,
Bernhard Voelker <=