From b2a7a91bbda918a44d703daea4cb1a59892684d4 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Sun, 23 Mar 2025 23:38:50 +0100 Subject: [PATCH] cppcheck memory leak --- tools/hitag2crack/crack2/ht2crack2search_multi.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/hitag2crack/crack2/ht2crack2search_multi.c b/tools/hitag2crack/crack2/ht2crack2search_multi.c index af2bf92ca..0649b5258 100644 --- a/tools/hitag2crack/crack2/ht2crack2search_multi.c +++ b/tools/hitag2crack/crack2/ht2crack2search_multi.c @@ -458,7 +458,16 @@ int main(int argc, char *argv[]) { // threads for (int i = 0; i < thread_count; ++i) { targs *a = calloc(1, rng.len + sizeof(targs)); + if (a == NULL) { + printf("Memory allocation failed for thread arguments\n"); + exit(1); + } a->r.data = calloc(1, rng.len); + if (a->r.data == NULL) { + printf("Memory allocation failed for rng data\n"); + free(a); + exit(1); + } a->thread = i; a->idx = i;