]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
tests: unit: add NULL-pointer check
authorPaolo Bonzini <pbonzini@redhat.com>
Mon, 5 Sep 2022 11:09:07 +0000 (13:09 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Sun, 18 Sep 2022 07:17:41 +0000 (09:17 +0200)
In CID 1432593, Coverity complains that the result of qdict_crumple()
might leak if it is not a dictionary.  This is not a practical concern
since the test would fail immediately with a NULL pointer dereference
in qdict_size().

However, it is not nice to depend on qdict_size() crashing, so add an
explicit assertion that that the crumpled object was indeed a dictionary.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
tests/unit/check-block-qdict.c

index 5a25825093016d1d75c7d77e9b12dc3fd691d801..751c58e73733ce4e77fd756900dc6fe74c29f3dc 100644 (file)
@@ -504,7 +504,7 @@ static void qdict_crumple_test_empty(void)
     src = qdict_new();
 
     dst = qobject_to(QDict, qdict_crumple(src, &error_abort));
-
+    g_assert(dst);
     g_assert_cmpint(qdict_size(dst), ==, 0);
 
     qobject_unref(src);