[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 05/11] qapi: fix leak in unit tests
From: |
Michael Roth |
Subject: |
[Qemu-devel] [PATCH 05/11] qapi: fix leak in unit tests |
Date: |
Fri, 10 May 2013 17:46:04 -0500 |
qmp_output_get_qobject() increments the qobject's reference count. Since
we currently pass this straight into qobject_to_json() so we can feed
the data into a QMP input visitor, we never actually free the underlying
qobject when qmp_output_visitor_cleanup() is called. This causes leaks
on all of the QMP serialization tests.
Fix this by holding a pointer to the qobject and decref'ing it before
returning from qmp_deserialize().
Signed-off-by: Michael Roth <address@hidden>
---
tests/test-visitor-serialization.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/tests/test-visitor-serialization.c
b/tests/test-visitor-serialization.c
index e84926f..8c8adac 100644
--- a/tests/test-visitor-serialization.c
+++ b/tests/test-visitor-serialization.c
@@ -657,11 +657,16 @@ static void qmp_deserialize(void **native_out, void
*datap,
VisitorFunc visit, Error **errp)
{
QmpSerializeData *d = datap;
- QString *output_json = qobject_to_json(qmp_output_get_qobject(d->qov));
- QObject *obj = qobject_from_json(qstring_get_str(output_json));
+ QString *output_json;
+ QObject *obj_orig, *obj;
+
+ obj_orig = qmp_output_get_qobject(d->qov);
+ output_json = qobject_to_json(obj_orig);
+ obj = qobject_from_json(qstring_get_str(output_json));
QDECREF(output_json);
d->qiv = qmp_input_visitor_new(obj);
+ qobject_decref(obj_orig);
qobject_decref(obj);
visit(qmp_input_get_visitor(d->qiv), native_out, errp);
}
--
1.7.9.5
- [Qemu-devel] [PATCH v3 00/11] qapi: add support for lists of native types, Michael Roth, 2013/05/10
- [Qemu-devel] [PATCH 01/11] qapi: qapi-types.py, native list support, Michael Roth, 2013/05/10
- [Qemu-devel] [PATCH 02/11] qapi: qapi-visit.py, fix list handling for union types, Michael Roth, 2013/05/10
- [Qemu-devel] [PATCH 03/11] qapi: qapi-visit.py, native list support, Michael Roth, 2013/05/10
- [Qemu-devel] [PATCH 04/11] qapi: enable generation of native list code, Michael Roth, 2013/05/10
- [Qemu-devel] [PATCH 05/11] qapi: fix leak in unit tests,
Michael Roth <=
- [Qemu-devel] [PATCH 06/11] json-parser: fix handling of large whole number values, Michael Roth, 2013/05/10
- [Qemu-devel] [PATCH 07/11] qapi: add QMP input test for large integers, Michael Roth, 2013/05/10
- [Qemu-devel] [PATCH 08/11] qapi: fix visitor serialization tests for numbers/doubles, Michael Roth, 2013/05/10
- [Qemu-devel] [PATCH 09/11] qapi: add native list coverage for visitor serialization tests, Michael Roth, 2013/05/10
- [Qemu-devel] [PATCH 10/11] qapi: add native list coverage for QMP output visitor tests, Michael Roth, 2013/05/10
- [Qemu-devel] [PATCH 11/11] qapi: add native list coverage for QMP input visitor tests, Michael Roth, 2013/05/10
- Re: [Qemu-devel] [PATCH v3 00/11] qapi: add support for lists of native types, Laszlo Ersek, 2013/05/13
- Re: [Qemu-devel] [PATCH v3 00/11] qapi: add support for lists of native types, Amos Kong, 2013/05/13
- Re: [Qemu-devel] [PATCH v3 00/11] qapi: add support for lists of native types, Luiz Capitulino, 2013/05/15