From: Ján Tomko Date: Fri, 1 Jul 2016 12:57:43 +0000 (+0200) Subject: examples: check asprintf return value in client_info.c X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=aa7bb4f36d87024e4c15e9fbef86119d9e0c9dca;p=libvirt.git 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. --- diff --git a/examples/admin/client_info.c b/examples/admin/client_info.c index dd0a04aa70..314a0902be 100644 --- a/examples/admin/client_info.c +++ b/examples/admin/client_info.c @@ -86,6 +86,11 @@ exampleGetTypedParamValue(virTypedParameterPtr item) return NULL; } + if (ret < 0) { + fprintf(stderr, "error formatting typed param value\n"); + return NULL; + } + return str; }