From: Michael Brown Date: Tue, 8 May 2012 20:04:57 +0000 (+0100) Subject: [image] Avoid potential NULL pointer dereference X-Git-Tag: v1.20.1~1796 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c124f21f5607c533c4099eeb5f6fe6e198bf0b3f;p=thirdparty%2Fipxe.git [image] Avoid potential NULL pointer dereference Detected using Valgrind. Signed-off-by: Michael Brown --- diff --git a/src/core/image.c b/src/core/image.c index 105809257..bf9bb7fae 100644 --- a/src/core/image.c +++ b/src/core/image.c @@ -96,9 +96,11 @@ struct image * alloc_image ( struct uri *uri ) { ref_init ( &image->refcnt, free_image ); if ( uri ) { image->uri = uri_get ( uri ); - name = basename ( ( char * ) uri->path ); - if ( ( rc = image_set_name ( image, name ) ) != 0 ) - goto err_set_name; + if ( uri->path ) { + name = basename ( ( char * ) uri->path ); + if ( ( rc = image_set_name ( image, name ) ) != 0 ) + goto err_set_name; + } } return image;