]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tests: check and handle error for virAsprintf() calls
authorJohn Ferlan <jferlan@redhat.com>
Thu, 3 Jan 2013 19:16:19 +0000 (14:16 -0500)
committerEric Blake <eblake@redhat.com>
Fri, 4 Jan 2013 17:57:20 +0000 (10:57 -0700)
tests/vmx2xmltest.c
tests/xml2vmxtest.c

index 03a8989983299a95db857a6b60bfc3fbd9854f4c..24303504aa9ca8e5bee641a356e4bc71d71692a7 100644 (file)
@@ -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:
index 653ab6cef3c21e82757e692cb2587af00c3164c8..c578109f18d60e12a2c3bd458a60dc0d2d9f514f 100644 (file)
@@ -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);