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>
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)