]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Avoid crash on OOM in virnetmessagetest
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 25 Sep 2013 14:36:39 +0000 (15:36 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Wed, 25 Sep 2013 17:12:09 +0000 (18:12 +0100)
The virnetmessagetest code did not check for failure to
allocate the message object. This lead to a crash on OOM
in the test suite.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
tests/virnetmessagetest.c

index 1aa4c25a660e0af47b73cb545501183cea8e7aec..3c9bead5d3bb2ca78116c1b8698f7b074e6fcc27 100644 (file)
@@ -327,6 +327,9 @@ static int testMessagePayloadDecode(const void *args ATTRIBUTE_UNUSED)
     };
     int ret = -1;
 
+    if (!msg)
+        return -1;
+
     msg->bufferLength = 4;
     if (VIR_ALLOC_N(msg->buffer, msg->bufferLength) < 0)
         goto cleanup;
@@ -476,6 +479,9 @@ static int testMessagePayloadStreamEncode(const void *args ATTRIBUTE_UNUSED)
     };
     int ret = -1;
 
+    if (!msg)
+        return -1;
+
     msg->header.prog = 0x11223344;
     msg->header.vers = 0x01;
     msg->header.proc = 0x666;