Skip to content

Commit eb75c89

Browse files
committed
hashsum: cleanup at exit
1 parent 312247f commit eb75c89

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

demos/hashsum.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@
3838

3939
static char* hashsum;
4040

41+
static void cleanup(void)
42+
{
43+
free(hashsum);
44+
}
45+
4146
static void die(int status)
4247
{
4348
unsigned long w, x;
@@ -53,7 +58,6 @@ static void die(int status)
5358
}
5459
}
5560
if (w != 0) fprintf(o, "\n");
56-
free(hashsum);
5761
exit(status);
5862
}
5963

@@ -173,6 +177,7 @@ int main(int argc, char **argv)
173177
unsigned char hash_buffer[MAXBLOCKSIZE];
174178

175179
hashsum = strdup(basename(argv[0]));
180+
atexit(cleanup);
176181

177182
/* You need to register algorithms before using them */
178183
register_all_ciphers();

0 commit comments

Comments
 (0)