summaryrefslogtreecommitdiffstats
path: root/src/image
diff options
context:
space:
mode:
authorMichael Brown2017-03-21 13:07:07 +0100
committerMichael Brown2017-03-21 13:07:40 +0100
commit36cffe054d2229ca21c093f28957e45fd09ba921 (patch)
treeefdf5ed87605978a4ff10f6983dbb37b2d9cf9a4 /src/image
parent[802.11] Remove redundant NULL pointer check after dereference (diff)
downloadipxe-36cffe054d2229ca21c093f28957e45fd09ba921.tar.gz
ipxe-36cffe054d2229ca21c093f28957e45fd09ba921.tar.xz
ipxe-36cffe054d2229ca21c093f28957e45fd09ba921.zip
[crypto] Free correct pointer on the error path
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/image')
-rw-r--r--src/image/pem.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/image/pem.c b/src/image/pem.c
index 721b11ec..3f5d1f30 100644
--- a/src/image/pem.c
+++ b/src/image/pem.c
@@ -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 ) );
@@ -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: