diff options
author | Michael Brown | 2012-05-08 22:04:57 +0200 |
---|---|---|
committer | Michael Brown | 2012-05-08 22:05:25 +0200 |
commit | c124f21f5607c533c4099eeb5f6fe6e198bf0b3f (patch) | |
tree | b299c410fe96093b9996b77f242d1fb0d5d6fcd8 /src/core/image.c | |
parent | [crypto] Automatically download cross-signed certificates (diff) | |
download | ipxe-c124f21f5607c533c4099eeb5f6fe6e198bf0b3f.tar.gz ipxe-c124f21f5607c533c4099eeb5f6fe6e198bf0b3f.tar.xz ipxe-c124f21f5607c533c4099eeb5f6fe6e198bf0b3f.zip |
[image] Avoid potential NULL pointer dereference
Detected using Valgrind.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/core/image.c')
-rw-r--r-- | src/core/image.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/core/image.c b/src/core/image.c index 10580925..bf9bb7fa 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; |