From e4d0bb45799a055f222704f66b0373697cbaa86d Mon Sep 17 00:00:00 2001 From: Simon Kelley Date: Fri, 6 Feb 2026 15:05:59 +0000 Subject: [PATCH] Convert hash_init() to use realloc(). --- src/crypto.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/crypto.c b/src/crypto.c index 6a5f0c1..92de2d9 100644 --- a/src/crypto.c +++ b/src/crypto.c @@ -126,20 +126,18 @@ int hash_init(const struct nettle_hash *hash, void **ctxp, unsigned char **diges if (ctx_sz < hash->context_size) { - if (!(new = whine_malloc(hash->context_size))) + if (!(new = whine_realloc(ctx, hash->context_size))) return 0; - if (ctx) - free(ctx); + ctx = new; ctx_sz = hash->context_size; } if (digest_sz < hash->digest_size) { - if (!(new = whine_malloc(hash->digest_size))) + if (!(new = whine_realloc(digest, hash->digest_size))) return 0; - if (digest) - free(digest); + digest = new; digest_sz = hash->digest_size; }