Skip to content

Commit 2e83abf

Browse files
Fix potential memory leak in RSAPSS (#1186)
When creating a new context with ICC_EVP_MD_CTX_new potential failures can occur. In the case that this API fails we should release the entire ockDigest structure upon failure. Fixes: #1138 Back-ported from: #1169 Signed-off-by: Jason Katonica <katonica@us.ibm.com>
1 parent 0c52ff7 commit 2e83abf

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/main/native/ock/RsaPss.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,7 @@ OCKDigest *allocateDigest(JNIEnv *env, ICC_CTX *ockCtx, jstring digestAlgo) {
548548
if (NULL == ockDigest->mdCtx) {
549549
ockCheckStatus(ockCtx);
550550
throwOCKException(env, 0, "ICC_EVP_MD_CTX_new failed");
551+
FREE_N_NULL(ockDigest);
551552
} else {
552553
ICC_EVP_MD_CTX_init(ockCtx, ockDigest->mdCtx);
553554
}

0 commit comments

Comments
 (0)