[PATCH 21/23] Avoid crash on OOM in virportallocatortest

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>

The virportallocatortest did not check if the object
allocation failed in all cases. This lead to a crash
on OOM in the testsuite

Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
---
 tests/virportallocatortest.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tests/virportallocatortest.c b/tests/virportallocatortest.c
index 1a0cdfa..615fa15 100644
--- a/tests/virportallocatortest.c
+++ b/tests/virportallocatortest.c
@@ -67,6 +67,9 @@ static int testAllocAll(const void *args ATTRIBUTE_UNUSED)
     int ret = -1;
     unsigned short p1, p2, p3, p4, p5, p6, p7;
 
+    if (!alloc)
+        return -1;
+
     if (virPortAllocatorAcquire(alloc, &p1) < 0)
         goto cleanup;
     if (p1 != 5901) {
@@ -137,6 +140,9 @@ static int testAllocReuse(const void *args ATTRIBUTE_UNUSED)
     int ret = -1;
     unsigned short p1, p2, p3, p4;
 
+    if (!alloc)
+        return -1;
+
     if (virPortAllocatorAcquire(alloc, &p1) < 0)
         goto cleanup;
     if (p1 != 5901) {
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]