[PATCH 1/2] Make sure that git_getpass() never returns NULL
- From
Pat Thoyts <patthoyts@users.sourceforge.net>
- Date
- Sep 29, 2010, 22:22 UTC
- Message-ID
- <1285798953-15320-2-git-send-email-patthoyts@users.sourceforge.net>
- In-Reply-To
- <7vocbhsn03.fsf@alter.siamese.dyndns.org>
From: Johannes Schindelin <johannes.schindelin@gmx.de>
The result of git_getpass() is used without checking for NULL, so let's just die() instead of returning NULL.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> --- connect.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/connect.c b/connect.c index 3450cab..57dc20c 100644 --- a/connect.c +++ b/connect.c @@ -631,8 +631,12 @@ char *git_getpass(const char *prompt) askpass = askpass_program; if (!askpass) askpass = getenv("SSH_ASKPASS"); - if (!askpass || !(*askpass)) - return getpass(prompt); + if (!askpass || !(*askpass)) { + char *result = getpass(prompt); + if (!result) + die_errno("Could not read password"); + return result; + } args[0] = askpass; args[1] = prompt;
-- 1.7.3