]> xenbits.xensource.com Git - xen.git/commitdiff
libxenstat: always free qmp_stats
authorWei Liu <wei.liu2@citrix.com>
Wed, 8 Apr 2015 16:08:21 +0000 (17:08 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Wed, 15 Apr 2015 16:10:58 +0000 (17:10 +0100)
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.liu2@citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Charles Arnold <carnold@suse.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
tools/xenstat/libxenstat/src/xenstat_qmp.c

index aad15c8196e2b18be706e63055fd7f2457a4dea3..8d91feffa107da945cb5e2b4cdd9126653721ba8 100644 (file)
@@ -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)