Fix Memory Leaks in IPP Crypto ML-DSA Implementation#112
Conversation
|
Are you sure about that? Why are you freeing memory only in error code path? The memory is only needed local to the function, no? |
|
The buffers (data->pk, data->sk, data->sig) are output parameters, not local scratch space. They are passed back to the caller, which assumes ownership of the memory and frees it after serialization (e.g., in vector_free_entry for JSON or proto_ml_dsa_keygen_tester for protobuf). Freeing them unconditionally here would cause a use-after-free for the caller. They are only freed in the error path to prevent leaking partially allocated output buffers if a failure occurs before the function completes.
|
|
Applied, thanks. |
I've fixed some memory leaks in the ML-DSA part of the IPP Crypto backend. Thanks @smuellerDD for pointing that out!
The issue was that several alloc_buf calls didn't have matching free_buf calls in the error paths. I’ve updated keygen, siggen, and the internal keygen helper to ensure all temporary and output buffers are properly cleaned up if something fails.