]> xenbits.xensource.com Git - people/dariof/libvirt.git/commitdiff
tests: Coverity found new NULL_RETURNS
authorJohn Ferlan <jferlan@redhat.com>
Thu, 1 Aug 2013 19:54:51 +0000 (15:54 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 1 Aug 2013 21:04:28 +0000 (17:04 -0400)
Coverity reported the existing missing check of the return value and
subsequent use from a call to virJSONValueFromString() in testJSONAddRemove().

tests/jsontest.c

index a37a98023879b2f1d17c5a942a481476cb0054d7..1d385d44b5c6f184d692ada2284a9959db4009e5 100644 (file)
@@ -60,11 +60,17 @@ testJSONAddRemove(const void *data)
 {
     const struct testInfo *info = data;
     virJSONValuePtr json;
-    virJSONValuePtr name;
+    virJSONValuePtr name = NULL;
     char *result = NULL;
     int ret = -1;
 
     json = virJSONValueFromString(info->doc);
+    if (!json) {
+        if (virTestGetVerbose())
+            fprintf(stderr, "Fail to parse %s\n", info->doc);
+        ret = -1;
+        goto cleanup;
+    }
 
     switch (virJSONValueObjectRemoveKey(json, "name", &name)) {
     case 1: