aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--qapi/qmp-output-visitor.c8
-rw-r--r--tests/test-qmp-output-visitor.c3
2 files changed, 8 insertions, 3 deletions
diff --git a/qapi/qmp-output-visitor.c b/qapi/qmp-output-visitor.c
index efc19d5841..8dce08749d 100644
--- a/qapi/qmp-output-visitor.c
+++ b/qapi/qmp-output-visitor.c
@@ -66,9 +66,13 @@ static QObject *qmp_output_first(QmpOutputVisitor *qov)
{
QStackEntry *e = QTAILQ_LAST(&qov->stack, QStack);
- /* FIXME - find a better way to deal with NULL values */
+ /*
+ * FIXME Wrong, because qmp_output_get_qobject() will increment
+ * the refcnt *again*. We need to think through how visitors
+ * handle null.
+ */
if (!e) {
- return NULL;
+ return qnull();
}
return e->value;
diff --git a/tests/test-qmp-output-visitor.c b/tests/test-qmp-output-visitor.c
index 338ada0253..a48ae72452 100644
--- a/tests/test-qmp-output-visitor.c
+++ b/tests/test-qmp-output-visitor.c
@@ -485,7 +485,8 @@ static void test_visitor_out_empty(TestOutputVisitorData *data,
QObject *arg;
arg = qmp_output_get_qobject(data->qov);
- g_assert(!arg);
+ g_assert(qobject_type(arg) == QTYPE_QNULL);
+ qobject_decref(arg);
}
static void init_native_list(UserDefNativeListUnion *cvalue)