Sfoglia il codice sorgente

[image] Avoid potential NULL pointer dereference

Detected using Valgrind.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 12 anni fa
parent
commit
c124f21f56
1 ha cambiato i file con 5 aggiunte e 3 eliminazioni
  1. 5
    3
      src/core/image.c

+ 5
- 3
src/core/image.c Vedi File

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

Loading…
Annulla
Salva