From eb75c894db2e35087a864db7773428b442e3d911 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Thu, 21 Sep 2017 16:13:22 +0200 Subject: [PATCH] hashsum: cleanup at exit --- demos/hashsum.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/demos/hashsum.c b/demos/hashsum.c index 83ab8c6..69dd2f2 100644 --- a/demos/hashsum.c +++ b/demos/hashsum.c @@ -38,6 +38,11 @@ static char* hashsum; +static void cleanup(void) +{ + free(hashsum); +} + static void die(int status) { unsigned long w, x; @@ -53,7 +58,6 @@ static void die(int status) } } if (w != 0) fprintf(o, "\n"); - free(hashsum); exit(status); } @@ -173,6 +177,7 @@ int main(int argc, char **argv) unsigned char hash_buffer[MAXBLOCKSIZE]; hashsum = strdup(basename(argv[0])); + atexit(cleanup); /* You need to register algorithms before using them */ register_all_ciphers();