浏览代码

[image] Avoid potential NULL pointer dereference

Detected using Valgrind.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 12 年前
父节点
当前提交
c124f21f56
共有 1 个文件被更改,包括 5 次插入3 次删除
  1. 5
    3
      src/core/image.c

+ 5
- 3
src/core/image.c 查看文件

@@ -96,9 +96,11 @@ struct image * alloc_image ( struct uri *uri ) {
96 96
 	ref_init ( &image->refcnt, free_image );
97 97
 	if ( uri ) {
98 98
 		image->uri = uri_get ( uri );
99
-		name = basename ( ( char * ) uri->path );
100
-		if ( ( rc = image_set_name ( image, name ) ) != 0 )
101
-			goto err_set_name;
99
+		if ( uri->path ) {
100
+			name = basename ( ( char * ) uri->path );
101
+			if ( ( rc = image_set_name ( image, name ) ) != 0 )
102
+				goto err_set_name;
103
+		}
102 104
 	}
103 105
 
104 106
 	return image;

正在加载...
取消
保存