From b546c7c926c8d713719a4ffd469a25cfda1c918e Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 9 Oct 2014 16:42:17 +0200 Subject: get_url_file_name: make no slash equal empty string --- src/tool_operhlp.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/tool_operhlp.c') 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 -- cgit v1.2.3