PkCtx double free fix#377
Conversation
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #377
Scan targets checked: wolfssljni-bugs, wolfssljni-src
No new issues found in the changed files. ✅
There was a problem hiding this comment.
Pull request overview
This PR addresses Issue #375 by eliminating a double-free / dangling-pointer hazard in the public-key callback context setters for WolfSSLSession by swapping in a fully-initialized replacement context before freeing the prior one.
Changes:
- Introduces
setPkCtxHelper()to atomically replace PK callbackinternCtxpointers (install new first, then free old). - Introduces
freePkCtx()and refactorsfreeSSL()PK-context cleanup to use it. - Ensures
NewGlobalRef()failure paths free the newly-allocated (but uninstalled)internCtx.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
11cc041 to
44f4c55
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #377
Scan targets checked: wolfssljni-bugs, wolfssljni-src
No new issues found in the changed files. ✅
|
@stenslae please rebase on master, which should pick up the fix needed for the Android Gradle test to pass, thanks. |
44f4c55 to
a4e8408
Compare
Issue #375 -- Reordered each setter to build the new internCtx fully, install it via wolfSSL_Set*Ctx(), and only then free the old one. Deduplicated the six setters and the freeSSL cleanup blocks into two helpers, setPkCtxHelper() and freePkCtx().