]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Avoid crash on OOM in virportallocatortest
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 25 Sep 2013 14:35:44 +0000 (15:35 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Wed, 25 Sep 2013 17:12:09 +0000 (18:12 +0100)
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@redhat.com>
tests/virportallocatortest.c

index 1a0cdfafd7dd1ceb342750d3e71728a5e808c86d..615fa15d054cec7493ca681c921a204c60069c12 100644 (file)
@@ -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) {