diff options
Diffstat (limited to 'src/tty-ask-password-agent.c')
-rw-r--r-- | src/tty-ask-password-agent.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/tty-ask-password-agent.c b/src/tty-ask-password-agent.c index b620aa6ee3..02b959ea59 100644 --- a/src/tty-ask-password-agent.c +++ b/src/tty-ask-password-agent.c @@ -376,15 +376,17 @@ static int parse_password(const char *filename, char **wall) { release_terminal(); } - packet_length = 1+strlen(password)+1; - if (!(packet = new(char, packet_length))) - r = -ENOMEM; - else { - packet[0] = '+'; - strcpy(packet+1, password); - } + if (r >= 0) { + packet_length = 1+strlen(password)+1; + if (!(packet = new(char, packet_length))) + r = -ENOMEM; + else { + packet[0] = '+'; + strcpy(packet+1, password); + } - free(password); + free(password); + } } if (r == -ETIME || r == -ENOENT) { |