qemuMonitorAddObject: Use g_clear_pointer for a free and reset operation

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2021-12-01 09:31:30 +01:00
parent b2899f0708
commit 377c3dd3b1
1 changed files with 3 additions and 4 deletions

View File

@ -2956,10 +2956,9 @@ qemuMonitorAddObject(qemuMonitor *mon,
ignore_value(virJSONValueObjectRemoveKey(*props, "qom-type", &typeobj));
ignore_value(virJSONValueObjectRemoveKey(*props, "id", &idobj));
if (!virJSONValueObjectGetKey(*props, 0)) {
virJSONValueFree(*props);
*props = NULL;
}
/* avoid empty 'props' member */
if (!virJSONValueObjectGetKey(*props, 0))
g_clear_pointer(props, virJSONValueFree);
if (virJSONValueObjectAdd(&pr,
"s:qom-type", type,