Skip to content

Commit

Permalink
[xen] Use standard calling pattern for asprintf()
Browse files Browse the repository at this point in the history
Our asprintf() implementation guarantees that strp will be NULL on
allocation failure, but this is not standard behaviour.  Detect errors
by checking for a negative return value instead of a NULL pointer.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed Mar 22, 2017
1 parent 21d8624 commit 01496a5
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/interface/xen/xenstore.c
Expand Up @@ -538,8 +538,7 @@ void xenstore_dump ( struct xen_hypervisor *xen, const char *key ) {
child += ( strlen ( child ) + 1 /* NUL */ ) ) {

/* Construct child key */
asprintf ( &child_key, "%s/%s", key, child );
if ( ! child_key ) {
if ( asprintf ( &child_key, "%s/%s", key, child ) < 0 ){
DBGC ( xen, "XENSTORE could not allocate child "
"key \"%s/%s\"\n", key, child );
rc = -ENOMEM;
Expand Down

0 comments on commit 01496a5

Please sign in to comment.