diff options
-rw-r--r-- | source3/lib/getsmbpass.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/source3/lib/getsmbpass.c b/source3/lib/getsmbpass.c index df5e0359aa..a7780f7c12 100644 --- a/source3/lib/getsmbpass.c +++ b/source3/lib/getsmbpass.c @@ -147,8 +147,10 @@ char *getsmbpass(const char *prompt) fgets(buf, bufsize, in); } nread = strlen(buf); - if (buf[nread - 1] == '\n') - buf[nread - 1] = '\0'; + if (nread) { + if (buf[nread - 1] == '\n') + buf[nread - 1] = '\0'; + } /* Restore echoing. */ if (echo_off) { |