From 51ecdeb5112fa21276e7ef5cb25a0c3989dee4e0 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Fri, 15 Nov 2024 14:10:34 +0100 Subject: [PATCH] now uses the correct realloc pattern with testing the reallocated pointer before assigning --- client/src/loclass/ikeys.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/client/src/loclass/ikeys.c b/client/src/loclass/ikeys.c index 9458f13ce..44b9234ee 100644 --- a/client/src/loclass/ikeys.c +++ b/client/src/loclass/ikeys.c @@ -562,7 +562,15 @@ void invert_hash0(uint8_t k[8]) { // Create new forks by duplicating existing uint64_t values int new_head = heads_count * 2; - hydra_heads = (uint64_t *)realloc(hydra_heads, new_head * sizeof(uint64_t)); + + // proper realloc pattern + uint64_t *ptmp = (uint64_t *)realloc(hydra_heads, new_head * sizeof(uint64_t)); + if (ptmp == NULL) { + PrintAndLogEx(FAILED, "failed to allocate memory"); + free(hydra_heads); + return; + } + hydra_heads = ptmp; // Duplicate all current values and add the value to both original and new ones for (int i = 0; i < heads_count; i++) {