mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 11:22:23 +00: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: e89acdbc3bbada2f3c1a591278bc975ddee2d5a9 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);
|
virJSONValue *stat = virJSONValueArrayGet(stats, j);
|
||||||
const char *name = NULL;
|
const char *name = NULL;
|
||||||
const char *tmp = NULL;
|
const char *tmp = NULL;
|
||||||
qemuMonitorQueryStatsSchemaData *data = NULL;
|
g_autofree qemuMonitorQueryStatsSchemaData *data = NULL;
|
||||||
int type = -1;
|
int type = -1;
|
||||||
int unit = -1;
|
int unit = -1;
|
||||||
|
|
||||||
@ -8632,7 +8632,9 @@ qemuMonitorJSONExtractQueryStatsSchema(virJSONValue *json)
|
|||||||
virJSONValueObjectGetNumberUint(stat, "bucket-size", &data->bucket_size) < 0)
|
virJSONValueObjectGetNumberUint(stat, "bucket-size", &data->bucket_size) < 0)
|
||||||
data->bucket_size = 0;
|
data->bucket_size = 0;
|
||||||
|
|
||||||
virHashAddEntry(schema, name, data);
|
if (virHashAddEntry(schema, name, data) < 0)
|
||||||
|
return NULL;
|
||||||
|
data = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user