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>
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;
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;
}
}