From 941e752d9019eb52b4c50dcabf5d8a75098b241a Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Thu, 28 Dec 2023 15:28:53 +0100 Subject: [PATCH] Make sure there cannot be a double free() --- src/userinput.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/userinput.c b/src/userinput.c index 2df2d3bf..ec19dbe2 100644 --- a/src/userinput.c +++ b/src/userinput.c @@ -242,6 +242,7 @@ static void pinentry_read_password(const char *pinentry, const char *hint, if (ret) log_error("Error: %s\n", retstr); free(retstr); + retstr = NULL; if (ret) goto out; @@ -250,6 +251,7 @@ static void pinentry_read_password(const char *pinentry, const char *hint, if (ret) log_error("Failed to set title: %s\n", retstr); free(retstr); + retstr = NULL; if (ret) goto out; @@ -258,6 +260,7 @@ static void pinentry_read_password(const char *pinentry, const char *hint, if (ret) log_error("Failed to set description: %s\n", retstr); free(retstr); + retstr = NULL; if (ret) goto out; @@ -267,6 +270,7 @@ static void pinentry_read_password(const char *pinentry, const char *hint, if (ret) log_error("Failed to set keyinfo\n"); free(escaped); + escaped = NULL; if (ret) goto out; @@ -274,9 +278,11 @@ static void pinentry_read_password(const char *pinentry, const char *hint, ret = pinentry_exchange(to_pinentry[1], from_pinentry[0], &retstr, "SETPROMPT %s\n", escaped); free(escaped); + escaped = NULL; if (ret) log_error("Failed to set prompt: %s\n", retstr); free(retstr); + retstr = NULL; if (ret) goto out; @@ -285,12 +291,14 @@ static void pinentry_read_password(const char *pinentry, const char *hint, if (ret) { log_error("Failed to get PIN: %s\n", retstr); free(retstr); + retstr = NULL; goto out; } if (retstr) { strncpy(pass, retstr, len); free(retstr); + retstr = NULL; } else { log_error("No password given\n"); }