diff --git a/lib/url.c b/lib/url.c
index a1174a63b5aa5efe2dadd20530a4e9f1b154a971..fe32cba777a3743e9a3d038c7416e86424840f2d 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -1501,8 +1501,14 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
      * user:password to use in the operation
      */
     {
-      char* userpwd = va_arg(param, char *);
-      char* separator = strchr(userpwd, ':');
+      char* userpwd;
+      char* separator;
+
+      userpwd = va_arg(param, char *);
+      if(userpwd == NULL)
+        break;
+
+      separator = strchr(userpwd, ':');
       if (separator != NULL) {
 
         /* store username part of option */