[Libguestfs] [PATCH 04/11] edit: fix small memory leak on error

Pino Toscano ptoscano at redhat.com
Fri Mar 3 14:32:58 UTC 2017


If guestfs_int_random_string fails, make sure to free the buffer
allocated as return string.
---
 common/edit/file-edit.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/edit/file-edit.c b/common/edit/file-edit.c
index 81b1f1f..b0347e7 100644
--- a/common/edit/file-edit.c
+++ b/common/edit/file-edit.c
@@ -325,6 +325,7 @@ generate_random_name (const char *filename)
    */
   if (guestfs_int_random_string (p, 8) == -1) {
     perror ("guestfs_int_random_string");
+    free (ret);
     return NULL;
   }
 
-- 
2.9.3




More information about the Libguestfs mailing list