]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[crypto] Free correct pointer on the error path
authorMichael Brown <mcb30@ipxe.org>
Tue, 21 Mar 2017 12:07:07 +0000 (14:07 +0200)
committerMichael Brown <mcb30@ipxe.org>
Tue, 21 Mar 2017 12:07:40 +0000 (14:07 +0200)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/image/pem.c

index 721b11ec6e51c41ebb13a8339ead145d613ae70c..3f5d1f302b09c8d6099f15416d99c1adc148b288 100644 (file)
@@ -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: