* lib/sha3.c (sha3_##SIZE##_buffer): Free ctx before returning. * lib/sha3.c (sha3_process_bytes): Simplify, and replace * with -. --- ChangeLog | 6 +++++- lib/sha3.c | 11 ++++++----- 2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog index cc847be3a1..47606778bc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,11 @@ 2026-02-22 Paul Eggert <[email protected]> + crypto/sha3: fix memory leak with OpenSSL wrapper + * lib/sha3.c (sha3_##SIZE##_buffer): + Free ctx before returning. + crypto/sha3: simplify full-block processing - * lib/sha3.c (sha3_process_bytes): Simplify. + * lib/sha3.c (sha3_process_bytes): Simplify, and replace * with -. crypto/sha3: fix partial-buffer bug * lib/sha3.c (sha3_process_bytes): diff --git a/lib/sha3.c b/lib/sha3.c index 7bf33dbf6b..f7ca3c4abb 100644 --- a/lib/sha3.c +++ b/lib/sha3.c @@ -393,11 +393,12 @@ sha3_finish_ctx (struct sha3_ctx *ctx, void *resbuf) sha3_##SIZE##_buffer (const char *buffer, size_t len, void *resblock) \ { \ struct sha3_ctx ctx; \ - if (! sha3_##SIZE##_init_ctx (&ctx)) \ - return NULL; \ - if (! sha3_process_bytes (buffer, len, &ctx)) \ - return NULL; \ - return sha3_finish_ctx (&ctx, resblock); \ + void *result = ((sha3_##SIZE##_init_ctx (&ctx) \ + && sha3_process_bytes (buffer, len, &ctx)) \ + ? sha3_finish_ctx (&ctx, resblock) \ + : NULL); \ + sha3_free_ctx (&ctx); \ + return result; \ } DEFINE_SHA3_BUFFER (224) -- 2.51.0
