From 5b2aab136412b837cd4417505a84f796b17d9bf5 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 25 Jun 2013 23:47:33 +0200 Subject: forgot to initialise memort for sets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- c/sha3sum.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'c') diff --git a/c/sha3sum.c b/c/sha3sum.c index 4c93833..122d6f4 100644 --- a/c/sha3sum.c +++ b/c/sha3sum.c @@ -50,7 +50,11 @@ inline void putchars(char* bytes, long n) */ SET set_new() { - return (void**)malloc(sizeof(void*) << 4); + long i; + void** rc = = (void**)malloc(sizeof(void*) << 4); + for (i = 0; i < 16; i++) + *(rc + i) = 0; + return rc; } @@ -90,7 +94,7 @@ void set_free(SET set) */ void set_add(SET set, char* item, long n) { - long i; + long i, j; void** at = set; for (i = 0; i < n; i++) { @@ -98,11 +102,19 @@ void set_add(SET set, char* item, long n) if (*(at + a)) at = (void**)*(at + a); else - at = (void**)(*(at + a) = (void*)malloc(sizeof(void*) << 4)); + { + at = (void**)(*(at + a) = (void*)malloc(sizeof(void*) << 4)); + for (j = 0; j < 16; j++) + *(at + j) = 0; + } if (*(at + b)) at = (void**)*(at + b); else - at = (void**)(*(at + b) = (void*)malloc(sizeof(void*) << 4)); + { + at = (void**)(*(at + b) = (void*)malloc(sizeof(void*) << 4)); + for (j = 0; j < 16; j++) + *(at + j) = 0; + } } } -- cgit v1.2.3-70-g09d2