Skip to content

Commit 21d465c

Browse files
author
Andras Fekete
committed
Fix possible double free
1 parent f8f080d commit 21d465c

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

wolfcrypt/src/asn.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37514,8 +37514,10 @@ int wc_MIME_parse_headers(char* in, int inLen, MimeHdr** headers)
3751437514
}
3751537515
else if (mimeStatus == MIME_BODYVAL && cur == ';' && pos >= 1) {
3751637516
end = pos-1;
37517-
if (bodyVal != NULL)
37517+
if (bodyVal != NULL) {
3751837518
XFREE(bodyVal, NULL, DYNAMIC_TYPE_PKCS7);
37519+
bodyVal = NULL;
37520+
}
3751937521
ret = wc_MIME_header_strip(curLine, &bodyVal, start, end);
3752037522
if (ret) {
3752137523
goto error;
@@ -37608,9 +37610,12 @@ int wc_MIME_parse_headers(char* in, int inLen, MimeHdr** headers)
3760837610
if (ret != 0)
3760937611
wc_MIME_free_hdrs(curHdr);
3761037612
wc_MIME_free_hdrs(nextHdr);
37611-
XFREE(nameAttr, NULL, DYNAMIC_TYPE_PKCS7);
37612-
XFREE(bodyVal, NULL, DYNAMIC_TYPE_PKCS7);
37613-
XFREE(nextParam, NULL, DYNAMIC_TYPE_PKCS7);
37613+
if (nameAttr != NULL)
37614+
XFREE(nameAttr, NULL, DYNAMIC_TYPE_PKCS7);
37615+
if (bodyVal != NULL)
37616+
XFREE(bodyVal, NULL, DYNAMIC_TYPE_PKCS7);
37617+
if (nextParam != NULL)
37618+
XFREE(nextParam, NULL, DYNAMIC_TYPE_PKCS7);
3761437619

3761537620
return ret;
3761637621
}

0 commit comments

Comments
 (0)