mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 09:17:52 +03: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:
parent
6eb02a0086
commit
a607baf65a
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user