diff --git a/src/main.c b/src/main.c
index a11f0277cfd881d9892a8663c77d813a812963b9..5439253d954cbeca165eebec2993c8c92d7a3b9d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1049,7 +1049,11 @@ static int str2offset(curl_off_t *val, char *str)
 static void checkpasswd(const char *kind, /* for what purpose */
                         char **userpwd) /* pointer to allocated string */
 {
-  char *ptr = strchr(*userpwd, ':');
+  char *ptr;
+  if(!*userpwd)
+    return;
+
+  ptr = strchr(*userpwd, ':');
   if(!ptr) {
     /* no password present, prompt for one */
     char passwd[256]="";