[Libguestfs] [PATCH] ext2: fix small memory leak on error

Richard W.M. Jones rjones at redhat.com
Tue Sep 9 17:00:40 UTC 2014


On Tue, Sep 09, 2014 at 02:48:12PM +0200, Pino Toscano wrote:
> When failing to read the output of `readlink -f`, free the memory buffer
> used for it.
> ---
>  src/ext2fs-c.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/src/ext2fs-c.c b/src/ext2fs-c.c
> index 9e0770a..f3ca7dc 100644
> --- a/src/ext2fs-c.c
> +++ b/src/ext2fs-c.c
> @@ -631,6 +631,7 @@ ext2_copy_file (struct ext2_data *data, const char *src, const char *dest)
>        }
>        if (fgets (new_dirname, PATH_MAX, fp) == NULL) {
>  	pclose (fp);
> +	free (new_dirname);
>  	goto cont;
>        }
>        pclose (fp);
> -- 
> 1.9.3

You'll find plenty of "memory leaks" in supermin since it deliberately
doesn't bother freeing memory in many cases, in order to be fast.  (It
is a short-lived program, so it doesn't matter)

But - ACK.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW




More information about the Libguestfs mailing list