Commit a82f1b76386f8b446ef8aebf4c5089d8db0aa30e

Collin Funk 2025-09-06T16:38:08

crypto/sha3-buffer, crypto/sha3: Protect against double frees (regr. today). * lib/sha3.c (sha3_free_ctx): Only free the EVP_MD_CTX if it is not NULL, and set it to NULL after freeing. (DEFINE_SHA3_INIT_CTX, sha3_finish_ctx, sha3_process_bytes): Leave freeing memory to the caller. * lib/sha3-stream.c (sha3_xxx_stream): Call sha3_free_ctx on success and if sha3_init_ctx fails. * tests/test-sha3-224-buffer.c (main): Add a test that would otherwise segfault without this patch. * tests/test-sha3-256-buffer.c (main): Likewise. * tests/test-sha3-384-buffer.c (main): Likewise. * tests/test-sha3-512-buffer.c (main): Likewise.