Browse Source

[crypto] Free correct pointer on the error path

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 7 years ago
parent
commit
36cffe054d
1 changed files with 4 additions and 3 deletions
  1. 4
    3
      src/image/pem.c

+ 4
- 3
src/image/pem.c View File

@@ -145,7 +145,7 @@ static int pem_asn1 ( struct image *image, size_t offset,
145 145
 	*cursor = malloc ( sizeof ( **cursor ) + decoded_max_len );
146 146
 	if ( ! *cursor ) {
147 147
 		rc = -ENOMEM;
148
-		goto err_alloc_decoded;
148
+		goto err_alloc_cursor;
149 149
 	}
150 150
 	decoded = ( ( ( void * ) *cursor ) + sizeof ( **cursor ) );
151 151
 
@@ -172,8 +172,9 @@ static int pem_asn1 ( struct image *image, size_t offset,
172 172
 	return offset;
173 173
 
174 174
  err_decode:
175
-	free ( decoded );
176
- err_alloc_decoded:
175
+	free ( *cursor );
176
+	*cursor = NULL;
177
+ err_alloc_cursor:
177 178
 	free ( encoded );
178 179
  err_alloc_encoded:
179 180
  err_end:

Loading…
Cancel
Save