mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
qemu: Avoid memory leak in qemuMonitorJSONExtractQueryStatsSchema
In a rare case when virHashAddEntry fails we would just leak the
structure we wanted to add to the hash table.
Fixes: e89acdbc3b
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
@@ -8596,7 +8596,7 @@ qemuMonitorJSONExtractQueryStatsSchema(virJSONValue *json)
|
||||
virJSONValue *stat = virJSONValueArrayGet(stats, j);
|
||||
const char *name = NULL;
|
||||
const char *tmp = NULL;
|
||||
qemuMonitorQueryStatsSchemaData *data = NULL;
|
||||
g_autofree qemuMonitorQueryStatsSchemaData *data = NULL;
|
||||
int type = -1;
|
||||
int unit = -1;
|
||||
|
||||
@@ -8632,7 +8632,9 @@ qemuMonitorJSONExtractQueryStatsSchema(virJSONValue *json)
|
||||
virJSONValueObjectGetNumberUint(stat, "bucket-size", &data->bucket_size) < 0)
|
||||
data->bucket_size = 0;
|
||||
|
||||
virHashAddEntry(schema, name, data);
|
||||
if (virHashAddEntry(schema, name, data) < 0)
|
||||
return NULL;
|
||||
data = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user