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

Pino Toscano
Fri, 03 Mar 2017 14:32:58 -0000

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