]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[image] Avoid potential NULL pointer dereference
authorMichael Brown <mcb30@ipxe.org>
Tue, 8 May 2012 20:04:57 +0000 (21:04 +0100)
committerMichael Brown <mcb30@ipxe.org>
Tue, 8 May 2012 20:05:25 +0000 (21:05 +0100)
Detected using Valgrind.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/core/image.c

index 1058092574e6e3dd5c7533174d2b1bf4133999ca..bf9bb7fae5183023d7a1f773e057c1ee35f171c4 100644 (file)
@@ -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;