]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
get_url_file_name: make no slash equal empty string
authorDaniel Stenberg <daniel@haxx.se>
Thu, 9 Oct 2014 14:42:17 +0000 (16:42 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 9 Oct 2014 14:42:17 +0000 (16:42 +0200)
src/tool_operhlp.c

index 4a13cf18656f841e90ff0d0814f59d764d3145dd..7a6ed2015642fd6182ccb0511dc0303aa2a9c5cc 100644 (file)
@@ -140,13 +140,16 @@ 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++;
-    *filename = strdup(pc);
-    if(!*filename)
-      return CURLE_OUT_OF_MEMORY;
-  }
+  else
+    /* no slash => empty string */
+    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