cooljeanius / trousers-0.3.11.2

forked from Sourceforge to get it working on OSX
BSD 3-Clause "New" or "Revised" License
1 stars 0 forks source link

Fix code scanning alert no. 5: Potential use after free #8

Closed cooljeanius closed 3 weeks ago

cooljeanius commented 3 weeks ago

Fixes https://github.com/cooljeanius/trousers-0.3.11.2/security/code-scanning/5

To fix the problem, we need to ensure that the pointer rsakey->key.algorithmParms.parms is not accessed after it has been freed unless it has been reallocated. The best way to fix this is to set the pointer to NULL immediately after freeing it. This way, any subsequent access to the pointer will be safe, as accessing a NULL pointer will not lead to undefined behavior.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.