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

Pino Toscano ptoscano at redhat.com
Tue Sep 9 12:48:12 UTC 2014


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




More information about the Libguestfs mailing list