aboutsummaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2022-09-05 13:09:07 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2022-09-18 09:17:41 +0200
commitb3a58a6ae346f14075af0df7f9903ad389c33dbd (patch)
treed7a6436587c6c508c4abca47d43b983132b969cd /tests/unit
parent5dc51100394206b4ca3fdcafb008de8f99fc4676 (diff)
downloadqemu-b3a58a6ae346f14075af0df7f9903ad389c33dbd.zip
qemu-b3a58a6ae346f14075af0df7f9903ad389c33dbd.tar.gz
qemu-b3a58a6ae346f14075af0df7f9903ad389c33dbd.tar.bz2
tests: unit: add NULL-pointer check
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>
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/check-block-qdict.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tests/unit/check-block-qdict.c b/tests/unit/check-block-qdict.c
index 5a25825..751c58e 100644
--- a/tests/unit/check-block-qdict.c
+++ b/tests/unit/check-block-qdict.c
@@ -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);