Revert "Update to 7.40.1"
[platform/upstream/curl.git] / src / tool_operhlp.c
index abf9496..15eefab 100644 (file)
@@ -140,16 +140,15 @@ CURLcode get_url_file_name(char **filename, const char *url)
     pc = url;
   pc = strrchr(pc, '/');
 
-  if(pc)
+  if(pc) {
     /* duplicate the string beyond the slash */
     pc++;
-  else
-    /* no slash => empty string */
-    pc = "";
-
-  *filename = strdup(pc);
-  if(!*filename)
-    return CURLE_OUT_OF_MEMORY;
+    if(*pc) {
+      *filename = strdup(pc);
+      if(!*filename)
+        return CURLE_OUT_OF_MEMORY;
+    }
+  }
 
   /* in case we built debug enabled, we allow an environment variable
    * named CURL_TESTDIR to prefix the given file name to put it into a
@@ -164,8 +163,6 @@ CURLcode get_url_file_name(char **filename, const char *url)
       Curl_safefree(*filename);
       *filename = strdup(buffer); /* clone the buffer */
       curl_free(tdir);
-      if(!*filename)
-        return CURLE_OUT_OF_MEMORY;
     }
   }
 #endif