mirror of
https://github.com/curl/curl.git
synced 2026-07-23 17:07:16 +03:00
tool_operate: avoid strlen() -1 on zero length content from file
Follow-up to 65b563a96a
Closes #11959
This commit is contained in:
parent
93885cf3a8
commit
c50cbac0f0
1 changed files with 5 additions and 6 deletions
|
|
@ -749,14 +749,13 @@ static char *ipfs_gateway(void)
|
|||
Curl_safefree(gateway_composed_file_path);
|
||||
|
||||
if(gateway_file) {
|
||||
char *gateway_buffer = NULL;
|
||||
char *buf = NULL;
|
||||
|
||||
if((PARAM_OK == file2string(&gateway_buffer, gateway_file)) &&
|
||||
gateway_buffer) {
|
||||
bool add_slash = (gateway_buffer[strlen(gateway_buffer) - 1] != '/');
|
||||
gateway = aprintf("%s%s", gateway_buffer, (add_slash) ? "/" : "");
|
||||
Curl_safefree(gateway_buffer);
|
||||
if((PARAM_OK == file2string(&buf, gateway_file)) && buf && *buf) {
|
||||
bool add_slash = (buf[strlen(buf) - 1] != '/');
|
||||
gateway = aprintf("%s%s", buf, (add_slash) ? "/" : "");
|
||||
}
|
||||
Curl_safefree(buf);
|
||||
|
||||
if(gateway_file)
|
||||
fclose(gateway_file);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue