aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2013-06-25 23:47:33 +0200
committerMattias Andrée <maandree@operamail.com>2013-06-25 23:47:33 +0200
commit5b2aab136412b837cd4417505a84f796b17d9bf5 (patch)
treeca5825879d91343d5fae46537d979ca1f9b55e54
parentadd python2 (diff)
downloadsha3sum-5b2aab136412b837cd4417505a84f796b17d9bf5.tar.gz
sha3sum-5b2aab136412b837cd4417505a84f796b17d9bf5.tar.bz2
sha3sum-5b2aab136412b837cd4417505a84f796b17d9bf5.tar.xz
forgot to initialise memort for sets
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r--c/sha3sum.c20
1 files changed, 16 insertions, 4 deletions
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;
+ }
}
}