From: John Ferlan Date: Thu, 3 Jan 2013 19:16:19 +0000 (-0500) Subject: tests: check and handle error for virAsprintf() calls X-Git-Tag: v1.0.2-rc1~298 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7ac12d84d0d19eb5e358ca5e9d9eeab67adb377e;p=thirdparty%2Flibvirt.git tests: check and handle error for virAsprintf() calls --- diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c index 03a8989983..24303504aa 100644 --- a/tests/vmx2xmltest.c +++ b/tests/vmx2xmltest.c @@ -179,7 +179,9 @@ testParseVMXFileName(const char *fileName, void *opaque ATTRIBUTE_UNUSED) goto cleanup; } - virAsprintf(&src, "[%s] %s", datastoreName, directoryAndFileName); + if (virAsprintf(&src, "[%s] %s", datastoreName, + directoryAndFileName) < 0) + goto cleanup; } else if (STRPREFIX(fileName, "/")) { /* Found absolute path referencing a file outside a datastore */ src = strdup(fileName); @@ -188,7 +190,8 @@ testParseVMXFileName(const char *fileName, void *opaque ATTRIBUTE_UNUSED) src = NULL; } else { /* Found single file name referencing a file inside a datastore */ - virAsprintf(&src, "[datastore] directory/%s", fileName); + if (virAsprintf(&src, "[datastore] directory/%s", fileName) < 0) + goto cleanup; } cleanup: diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c index 653ab6cef3..c578109f18 100644 --- a/tests/xml2vmxtest.c +++ b/tests/xml2vmxtest.c @@ -193,8 +193,9 @@ testFormatVMXFileName(const char *src, void *opaque ATTRIBUTE_UNUSED) directoryAndFileName += strspn(directoryAndFileName, " "); } - virAsprintf(&absolutePath, "/vmfs/volumes/%s/%s", datastoreName, - directoryAndFileName); + if (virAsprintf(&absolutePath, "/vmfs/volumes/%s/%s", datastoreName, + directoryAndFileName) < 0) + goto cleanup; } else if (STRPREFIX(src, "/")) { /* Found absolute path */ absolutePath = strdup(src);