david/ipxe
david
/
ipxe
Archived
1
0
Fork 0

[xen] Use standard calling pattern for asprintf()

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>
This commit is contained in:
Michael Brown 2017-03-22 14:41:01 +02:00
parent 21d8624da8
commit 01496a5028
1 changed files with 1 additions and 2 deletions

View File

@ -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;