xenstore_client: handle memory on error
authorNorbert Manthey <nmanthey@amazon.de>
Fri, 26 Feb 2021 14:41:38 +0000 (15:41 +0100)
committerJulien Grall <jgrall@amazon.com>
Thu, 1 Apr 2021 16:12:05 +0000 (17:12 +0100)
commit00948dcd6a5412695b42c6d5045b0d3075b14114
treedb8082d32f56eba67cc26bf2d24e619b78fa8cf9
parent9617d5f9c19d1d157629e1e436791509526e0ce5
xenstore_client: handle memory on error

In case a command fails, also free the memory. As this is for the CLI
client, currently the leaked memory is freed right after receiving the
error, as the application terminates next.

Similarly, if the allocation fails, do not use the NULL pointer
afterwards, but instead error out.

This bug was discovered and resolved using Coverity Static Analysis
Security Testing (SAST) by Synopsys, Inc.

Signed-off-by: Norbert Manthey <nmanthey@amazon.de>
Reviewed-by: Thomas Friebel <friebelt@amazon.de>
Reviewed-by: Julien Grall <jgrall@amazon.co.uk>
Reviewed-by: Juergen Gross <jgross@suse.com>
tools/xenstore/xenstore_client.c