[client] fix minor memory leak in getpasswd() routine caught by the test suite in...
authorMichael Rash <mbr@cipherdyne.org>
Thu, 18 Jul 2013 21:30:25 +0000 (17:30 -0400)
committerMichael Rash <mbr@cipherdyne.org>
Thu, 18 Jul 2013 21:30:25 +0000 (17:30 -0400)
client/getpasswd.c

index 0db52c5..b3d4ba5 100644 (file)
@@ -68,6 +68,9 @@ read_passwd_from_stream(FILE *stream)
 
     ptr = ARRAY_FIRST_ELT_ADR(password);
 
+    if(stream == NULL)
+        return password;
+
 #ifdef WIN32
     while((c = _getch()) != PW_CR_CHAR)
 #else
@@ -192,6 +195,9 @@ getpasswd(const char *prompt, int fd)
     _putch(PW_CR_CHAR);
     _putch(PW_LF_CHAR);
 #endif
+
+    fclose(fp);
+
     return (ptr);
 }