[Libguestfs] [PATCH v3 1/3] do_btrfs_qgroup_show: fix a bad return value

Chen Hanxiao chenhanxiao at cn.fujitsu.com
Mon Jun 15 03:49:35 UTC 2015


We should not use tmp lines buffer as return value,
for lines buffer will be freed.

Signed-off-by: Chen Hanxiao <chenhanxiao at cn.fujitsu.com>
---
v3: don't return internal tmp values.

 daemon/btrfs.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index 39392f7..5011ec4 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -1254,7 +1254,7 @@ do_btrfs_qgroup_show (const char *path)
   CLEANUP_FREE char *err = NULL;
   CLEANUP_FREE char *out = NULL;
   int r;
-  char **lines;
+  CLEANUP_FREE_STRING_LIST char **lines = NULL;
 
   path_buf = sysroot_path (path);
   if (path_buf == NULL) {
@@ -1320,14 +1320,14 @@ do_btrfs_qgroup_show (const char *path)
       goto error;
     }
     *p = '\0';
-    this->btrfsqgroup_id = line;
+    this->btrfsqgroup_id = strdup (line);
+    if (this->btrfsqgroup_id == NULL)
+      goto error;
   }
 
-  free (lines);
   return ret;
 
 error:
-  free_stringslen (lines, nr_qgroups + 2);
   if (ret)
     free (ret->guestfs_int_btrfsqgroup_list_val);
   free (ret);
-- 
2.1.0




More information about the Libguestfs mailing list