[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 10/12] test-resv-mem: Fix CID 1523911
|
From: |
Thomas Huth |
|
Subject: |
[PULL 10/12] test-resv-mem: Fix CID 1523911 |
|
Date: |
Mon, 13 Nov 2023 12:07:38 +0100 |
From: Eric Auger <eric.auger@redhat.com>
Coverity complains about passing "&expected" to "run_range_inverse_array",
which dereferences null "expected". I guess the problem is that the
compare_ranges() loop dereferences 'e' without testing it. However the
loop condition is based on 'ranges' which is garanteed to have
the same length as 'expected' given the g_assert_cmpint() just
before the loop. So the code looks safe to me.
Nevertheless adding a test on expected before the loop to get rid of the
warning.
Fixes: CID 1523901
Signed-off-by: Eric Auger <eric.auger@redhat.com>
Reported-by: Coverity (CID 1523901)
Message-ID: <20231110083654.277345-1-eric.auger@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tests/unit/test-resv-mem.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tests/unit/test-resv-mem.c b/tests/unit/test-resv-mem.c
index 5963274e2c..cd8f7318cc 100644
--- a/tests/unit/test-resv-mem.c
+++ b/tests/unit/test-resv-mem.c
@@ -44,6 +44,10 @@ static void compare_ranges(const char *prefix, GList *ranges,
print_ranges("out", ranges);
print_ranges("expected", expected);
#endif
+ if (!expected) {
+ g_assert_true(!ranges);
+ return;
+ }
g_assert_cmpint(g_list_length(ranges), ==, g_list_length(expected));
for (l = ranges, e = expected; l ; l = l->next, e = e->next) {
Range *r = (Range *)l->data;
--
2.41.0
- [PULL 01/12] host/include/generic/host/atomic128: Fix compilation problem with Clang 17, (continued)
- [PULL 01/12] host/include/generic/host/atomic128: Fix compilation problem with Clang 17, Thomas Huth, 2023/11/13
- [PULL 02/12] s390x/pci: bypass vfio DMA counting when using cdev, Thomas Huth, 2023/11/13
- [PULL 03/12] s390x/pci: only limit DMA aperture if vfio DMA limit reported, Thomas Huth, 2023/11/13
- [PULL 04/12] MAINTAINERS: Add include/hw/input/pl050.h to the PrimeCell/CMSDK section, Thomas Huth, 2023/11/13
- [PULL 05/12] MAINTAINERS: Add hw/input/ads7846.c to the PXA2XX section, Thomas Huth, 2023/11/13
- [PULL 06/12] MAINTAINERS: Add hw/display/sii9022.c to the Versatile Express section, Thomas Huth, 2023/11/13
- [PULL 07/12] MAINTAINERS: Extend the Stellaris section, Thomas Huth, 2023/11/13
- [PULL 08/12] MAINTAINERS: Add a general architecture section for x86, Thomas Huth, 2023/11/13
- [PULL 09/12] tests/vm/netbsd: Use Python v3.11, Thomas Huth, 2023/11/13
- [PULL 11/12] tests/tsan: Rename the file with the entries that should be ignored, Thomas Huth, 2023/11/13
- [PULL 10/12] test-resv-mem: Fix CID 1523911,
Thomas Huth <=
- [PULL 12/12] hw/audio/es1370: Clean up comment, Thomas Huth, 2023/11/13
- Re: [PULL 00/12] Misc patches for 8.2-rc0, Stefan Hajnoczi, 2023/11/13