Skip to content

Commit 5fdf32d

Browse files
committed
Fix to make sure a double free cannot occur (ZD 21093)
1 parent 5b9d0a1 commit 5fdf32d

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

wolfcrypt/src/asn.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18413,6 +18413,7 @@ void FreeSignatureCtx(SignatureCtx* sigCtx)
1841318413
if (sigCtx->key.ecc->nb_ctx != NULL) {
1841418414
XFREE(sigCtx->key.ecc->nb_ctx, sigCtx->heap,
1841518415
DYNAMIC_TYPE_TMP_BUFFER);
18416+
sigCtx->key.ecc->nb_ctx = NULL;
1841618417
}
1841718418
#endif /* WC_ECC_NONBLOCK && WOLFSSL_ASYNC_CRYPT_SW &&
1841818419
WC_ASYNC_ENABLE_ECC */
@@ -18488,6 +18489,7 @@ void FreeSignatureCtx(SignatureCtx* sigCtx)
1848818489
#ifndef WOLFSSL_NO_MALLOC
1848918490
sigCtx->key.ptr = NULL;
1849018491
#endif
18492+
sigCtx->keyOID = 0; /* mark key as freed (guards re-entry without malloc) */
1849118493
}
1849218494
#endif /* !NO_ASN_CRYPT */
1849318495

0 commit comments

Comments
 (0)