From aa7bb4f36d87024e4c15e9fbef86119d9e0c9dca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Fri, 1 Jul 2016 14:57:43 +0200 Subject: [PATCH] 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. --- examples/admin/client_info.c | 5 +++++ 1 file changed, 5 insertions(+) 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; }