From babf2ff29cda90ceadcb2af593f264575dee0faf Mon Sep 17 00:00:00 2001 From: Seppia Date: Thu, 5 Jul 2018 16:20:56 +0200 Subject: Missing string memory deallocation Adds missing free function for dinamically allocated string and also moves a variable declaration to the appropriate block. --- src/onetimebluh.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/onetimebluh.c b/src/onetimebluh.c index dce4a6b..4cbd99a 100644 --- a/src/onetimebluh.c +++ b/src/onetimebluh.c @@ -357,8 +357,9 @@ void keyrand (Opts* opzioni) { unsigned char* key = malloc (opzioni->nbytes); RAND_bytes (key, opzioni->nbytes); - FILE* file; if (opzioni->output) { + FILE* file; + file = fopen (opzioni->output, "w"); fwrite (key, sizeof(char), opzioni->nbytes, file); fclose (file); @@ -373,6 +374,7 @@ void keyrand (Opts* opzioni) { } fprintf (stdout, "%s", key); + free (key); if (!opzioni->quiet) { printf ("\n"); -- cgit v1.2.3