From d42dfc07028fc77e9be0b1baca2aa4fd96214e98 Mon Sep 17 00:00:00 2001 From: Nicholas Tay Date: Tue, 11 Jan 2022 21:50:37 +1100 Subject: Fix potential invalid free on password ptr --- passgen.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/passgen.c b/passgen.c index 568f456..e841994 100644 --- a/passgen.c +++ b/passgen.c @@ -45,7 +45,7 @@ #ifdef USE_WINCRYPT -HCRYPTPROV win_rng; +HCRYPTPROV win_rng = NULL; #endif bool init_rng(void) { @@ -116,6 +116,7 @@ int main(int argc, char *argv[]) bool custom_grammar = false; char *grammar = DEFAULT_GRAMMAR; int grammar_size = sizeof(DEFAULT_GRAMMAR) - 1; + char *password = NULL; if (argc == 2) { /* Take first argument as the grammar */ @@ -134,7 +135,7 @@ int main(int argc, char *argv[]) custom_grammar = true; } - char *password = malloc(grammar_size + 1); + password = malloc(grammar_size + 1); if (password == NULL) { perror("malloc"); err = true; -- cgit