Skip to content

Commit

Permalink
[crypto] Free correct pointer on the error path
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed Mar 21, 2017
1 parent 9b58115 commit 36cffe0
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/image/pem.c
Expand Up @@ -145,7 +145,7 @@ static int pem_asn1 ( struct image *image, size_t offset,
*cursor = malloc ( sizeof ( **cursor ) + decoded_max_len );
if ( ! *cursor ) {
rc = -ENOMEM;
goto err_alloc_decoded;
goto err_alloc_cursor;
}
decoded = ( ( ( void * ) *cursor ) + sizeof ( **cursor ) );

Expand All @@ -172,8 +172,9 @@ static int pem_asn1 ( struct image *image, size_t offset,
return offset;

err_decode:
free ( decoded );
err_alloc_decoded:
free ( *cursor );
*cursor = NULL;
err_alloc_cursor:
free ( encoded );
err_alloc_encoded:
err_end:
Expand Down

0 comments on commit 36cffe0

Please sign in to comment.