pc = url;
pc = strrchr(pc, '/');
- if(pc) {
+ if(pc)
/* duplicate the string beyond the slash */
pc++;
- if(*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
Curl_safefree(*filename);
*filename = strdup(buffer); /* clone the buffer */
curl_free(tdir);
+ if(!*filename)
+ return CURLE_OUT_OF_MEMORY;
}
}
#endif