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
 	*cursor = malloc ( sizeof ( **cursor ) + decoded_max_len );
145
 	*cursor = malloc ( sizeof ( **cursor ) + decoded_max_len );
146
 	if ( ! *cursor ) {
146
 	if ( ! *cursor ) {
147
 		rc = -ENOMEM;
147
 		rc = -ENOMEM;
148
-		goto err_alloc_decoded;
148
+		goto err_alloc_cursor;
149
 	}
149
 	}
150
 	decoded = ( ( ( void * ) *cursor ) + sizeof ( **cursor ) );
150
 	decoded = ( ( ( void * ) *cursor ) + sizeof ( **cursor ) );
151
 
151
 
172
 	return offset;
172
 	return offset;
173
 
173
 
174
  err_decode:
174
  err_decode:
175
-	free ( decoded );
176
- err_alloc_decoded:
175
+	free ( *cursor );
176
+	*cursor = NULL;
177
+ err_alloc_cursor:
177
 	free ( encoded );
178
 	free ( encoded );
178
  err_alloc_encoded:
179
  err_alloc_encoded:
179
  err_end:
180
  err_end:

Loading…
Cancel
Save