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

[libvirt] [PATCH] tests: avoid NULL deref upon OOM failure



Pretty obvious:

>From 3e79d8839c5051461197a7c484adb32f7f04377a Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering redhat com>
Date: Tue, 16 Feb 2010 09:36:57 +0100
Subject: [PATCH] tests: avoid NULL deref upon OOM failure

* tests/qemuxml2argvtest.c (testCompareXMLToArgvFiles): Handle malloc
failure.
---
 tests/qemuxml2argvtest.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 3ee71a3..aa42f99 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -98,7 +98,8 @@ static int testCompareXMLToArgvFiles(const char *xml,
         len += strlen(*tmp) + 1;
         tmp++;
     }
-    actualargv = malloc(sizeof(*actualargv)*len);
+    if ((actualargv = malloc(sizeof(*actualargv)*len)) == NULL)
+        goto fail;
     actualargv[0] = '\0';
     tmp = qenv;
     while (*tmp) {
--
1.7.0.181.g41533


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