Ver código fonte

[image] Avoid potential NULL pointer dereference

Detected using Valgrind.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 12 anos atrás
pai
commit
c124f21f56
1 arquivos alterados com 5 adições e 3 exclusões
  1. 5
    3
      src/core/image.c

+ 5
- 3
src/core/image.c Ver arquivo

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

Carregando…
Cancelar
Salvar