Originally qmp_stats is only freed in failure path and leaked in success
path.

Instead of wiring up the success path, rearrange the code a bit to
always free qmp_stats before checking if info is NULL.

Signed-off-by: Wei Liu <wei.l...@citrix.com>
Cc: Ian Campbell <ian.campb...@citrix.com>
Cc: Ian Jackson <ian.jack...@eu.citrix.com>
Cc: Charles Arnold <carn...@suse.com>
Acked-by: Ian Jackson <ian.jack...@eu.citrix.com>
---
 tools/xenstat/libxenstat/src/xenstat_qmp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/xenstat/libxenstat/src/xenstat_qmp.c 
b/tools/xenstat/libxenstat/src/xenstat_qmp.c
index aad15c8..8d91fef 100644
--- a/tools/xenstat/libxenstat/src/xenstat_qmp.c
+++ b/tools/xenstat/libxenstat/src/xenstat_qmp.c
@@ -95,10 +95,10 @@ static char *qmp_get_block_image(xenstat_node *node, char 
*qmp_devname, int qfd)
                return NULL;
 
        /* Use libyajl version 2.0.3 or newer for the tree parser feature with 
bug fixes */
-       if ((info = yajl_tree_parse((char *)qmp_stats, NULL, 0)) == NULL) {
-               free(qmp_stats);
+       info = yajl_tree_parse((char *)qmp_stats, NULL, 0);
+       free(qmp_stats);
+       if (info == NULL)
                return NULL;
-       }
 
        ptr[0] = qblock[QMP_BLOCK_RETURN]; /* "return" */
        if ((ret_obj = yajl_tree_get(info, ptr, yajl_t_array)) == NULL)
-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

Reply via email to