From: Michael Brown Date: Tue, 21 Mar 2017 12:07:07 +0000 (+0200) Subject: [crypto] Free correct pointer on the error path X-Git-Tag: v1.20.1~281 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=36cffe054d2229ca21c093f28957e45fd09ba921;p=thirdparty%2Fipxe.git [crypto] Free correct pointer on the error path Signed-off-by: Michael Brown --- diff --git a/src/image/pem.c b/src/image/pem.c index 721b11ec6..3f5d1f302 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: