[libvirt] [PATCH 1/2] tests: Coverity found new NULL_RETURNS
Eric Blake
eblake at redhat.com
Thu Aug 1 20:12:12 UTC 2013
On 08/01/2013 02:06 PM, John Ferlan wrote:
> Coverity reported the existing missing check of the return value and
> subsequent use from a call to virJSONValueFromString() in testJSONAddRemove().
> ---
> tests/jsontest.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
ACK.
>
> diff --git a/tests/jsontest.c b/tests/jsontest.c
> index a37a980..1d385d4 100644
> --- a/tests/jsontest.c
> +++ b/tests/jsontest.c
> @@ -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:
>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130801/3fdf68bd/attachment-0001.sig>
More information about the libvir-list
mailing list