40 lines
1.4 KiB
Diff
40 lines
1.4 KiB
Diff
|
|
From f2f914e1868a83ffef1580465988557df0257bc6 Mon Sep 17 00:00:00 2001
|
||
|
|
From: tangbinzy <tangbin_yewu@cmss.chinamobile.com>
|
||
|
|
Date: Mon, 9 Sep 2024 07:54:12 +0000
|
||
|
|
Subject: [PATCH] tests: unit: add NULL-pointer check mainline inclusion commit
|
||
|
|
b3a58a6ae346f14075af0df7f9903ad389c33dbd category: bugfix
|
||
|
|
|
||
|
|
---------------------------------------------------------------
|
||
|
|
|
||
|
|
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>
|
||
|
|
|
||
|
|
Signed-off-by: tangbinzy <tangbin_yewu@cmss.chinamobile.com>
|
||
|
|
---
|
||
|
|
tests/unit/check-block-qdict.c | 2 +-
|
||
|
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||
|
|
|
||
|
|
diff --git a/tests/unit/check-block-qdict.c b/tests/unit/check-block-qdict.c
|
||
|
|
index 5a25825093..751c58e737 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);
|
||
|
|
--
|
||
|
|
2.41.0.windows.1
|
||
|
|
|