From: Marc-André Lureau <[email protected]>
Free owned resources on object finalization.
Fixes: 6ba7ada3559e ("qtest: add a QOM object for qtest")
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Marc-André Lureau <[email protected]>
---
system/qtest.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/system/qtest.c b/system/qtest.c
index cf90cd53adb..a79d10d1361 100644
--- a/system/qtest.c
+++ b/system/qtest.c
@@ -1020,10 +1020,20 @@ static void qtest_class_init(ObjectClass *oc, const
void *data)
qtest_get_log, qtest_set_log);
}
+static void qtest_finalize(Object *obj)
+{
+ QTest *q = QTEST(obj);
+
+ g_free(q->chr_name);
+ g_free(q->log);
+ object_unref(q->chr);
+}
+
static const TypeInfo qtest_info = {
.name = TYPE_QTEST,
.parent = TYPE_OBJECT,
.class_init = qtest_class_init,
+ .instance_finalize = qtest_finalize,
.instance_size = sizeof(QTest),
.interfaces = (const InterfaceInfo[]) {
{ TYPE_USER_CREATABLE },
--
2.54.0