瀏覽代碼

[crypto] Free correct pointer on the error path

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 7 年之前
父節點
當前提交
36cffe054d
共有 1 個文件被更改,包括 4 次插入3 次删除
  1. 4
    3
      src/image/pem.c

+ 4
- 3
src/image/pem.c 查看文件

@@ -145,7 +145,7 @@ static int pem_asn1 ( struct image *image, size_t offset,
145 145
 	*cursor = malloc ( sizeof ( **cursor ) + decoded_max_len );
146 146
 	if ( ! *cursor ) {
147 147
 		rc = -ENOMEM;
148
-		goto err_alloc_decoded;
148
+		goto err_alloc_cursor;
149 149
 	}
150 150
 	decoded = ( ( ( void * ) *cursor ) + sizeof ( **cursor ) );
151 151
 
@@ -172,8 +172,9 @@ static int pem_asn1 ( struct image *image, size_t offset,
172 172
 	return offset;
173 173
 
174 174
  err_decode:
175
-	free ( decoded );
176
- err_alloc_decoded:
175
+	free ( *cursor );
176
+	*cursor = NULL;
177
+ err_alloc_cursor:
177 178
 	free ( encoded );
178 179
  err_alloc_encoded:
179 180
  err_end:

Loading…
取消
儲存