From b78fddea39f7099766ed50efd04ceecb8b8fc857 Mon Sep 17 00:00:00 2001 From: Jim Meyering 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 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 3ee71a3b1..aa42f996e 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) { -- 2.39.5