diff options
author | Seppia <seppia@seppio.fish> | 2018-07-05 16:20:56 +0200 |
---|---|---|
committer | Seppia <seppia@seppio.fish> | 2018-07-05 16:20:56 +0200 |
commit | babf2ff29cda90ceadcb2af593f264575dee0faf (patch) | |
tree | f22e8a9421abde147619bb2e3d1b26bfa90ca6d5 /src | |
parent | 35748b207e9b32e59fb391d25d9fe8b4da403855 (diff) | |
download | onetimebluh-babf2ff29cda90ceadcb2af593f264575dee0faf.tar.gz onetimebluh-babf2ff29cda90ceadcb2af593f264575dee0faf.tar.bz2 onetimebluh-babf2ff29cda90ceadcb2af593f264575dee0faf.zip |
Missing string memory deallocation
Adds missing free function for dinamically allocated string and also
moves a variable declaration to the appropriate block.
Diffstat (limited to 'src')
-rw-r--r-- | src/onetimebluh.c | 4 |
1 files changed, 3 insertions, 1 deletions
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"); |