]> xenbits.xensource.com Git - libvirt.git/commitdiff
examples: check asprintf return value in client_info.c
authorJán Tomko <jtomko@redhat.com>
Fri, 1 Jul 2016 12:57:43 +0000 (14:57 +0200)
committerJán Tomko <jtomko@redhat.com>
Fri, 1 Jul 2016 13:39:01 +0000 (15:39 +0200)
On error, asprintf returns -1 and the contents of the string
pointer is undefined. In the rest of the libvirt code,
the virAsprintf wrapper takes care of that.

Check the return value and report a generic error, since we
purposefully avoid linking to virutil.

examples/admin/client_info.c

index dd0a04aa70eb1ebf2bfd38e86c18ec2673510357..314a0902be0aa09cded2fa2464f23056998f4d20 100644 (file)
@@ -86,6 +86,11 @@ exampleGetTypedParamValue(virTypedParameterPtr item)
         return NULL;
     }
 
+    if (ret < 0) {
+        fprintf(stderr, "error formatting typed param value\n");
+        return NULL;
+    }
+
     return str;
 }