aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Tay <nick@windblume.net>2022-01-11 21:50:37 +1100
committerNicholas Tay <nick@windblume.net>2022-01-11 21:50:42 +1100
commitd42dfc07028fc77e9be0b1baca2aa4fd96214e98 (patch)
treef5e08943fdef0eca3cdb4985d8390c87086f3c84
parent887ea0ad480c92679c71e3f88015fffe9c897ac2 (diff)
downloadpassgen-d42dfc07028fc77e9be0b1baca2aa4fd96214e98.tar.gz
passgen-d42dfc07028fc77e9be0b1baca2aa4fd96214e98.tar.bz2
passgen-d42dfc07028fc77e9be0b1baca2aa4fd96214e98.zip
Fix potential invalid free on password ptr
-rw-r--r--passgen.c5
1 files 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;