diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/tool_operhlp.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/tool_operhlp.c b/src/tool_operhlp.c index 4a13cf186..7a6ed2015 100644 --- a/src/tool_operhlp.c +++ b/src/tool_operhlp.c @@ -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 |