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. 4: Potential use after free #10

Closed cooljeanius closed 3 weeks ago

cooljeanius commented 3 weeks ago

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

To fix the problem, we need to ensure that the digest pointer is only used if the malloc call is successful. If malloc fails, we should avoid dereferencing digest and handle the error appropriately. This can be done by adding a check to ensure that digest is not used if malloc fails.

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