examples: check asprintf return value in client_info.c

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.
This commit is contained in:
Ján Tomko 2016-07-01 14:57:43 +02:00
parent 8764c99a40
commit aa7bb4f36d

View File

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