tool_operate: fix minor memory-leak on early error

When .curlrc is parsed successfully but the tool exits early before
parse_args() executes; the allocated path was not freed.

Spotted by Codex Security

Closes #20954
This commit is contained in:
Daniel Stenberg 2026-03-17 13:19:25 +01:00
parent b881bc0021
commit 90b9f51458
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2

View file

@ -2296,7 +2296,6 @@ CURLcode operate(int argc, argv_item_t argv[])
if(found_curlrc) {
/* After parse_args so notef knows the verbosity */
notef("Read config file from '%s'", curlrc_path);
curlx_free(curlrc_path);
}
if(err) {
result = CURLE_OK;
@ -2394,7 +2393,7 @@ CURLcode operate(int argc, argv_item_t argv[])
errorf("out of memory");
}
}
curlx_free(curlrc_path);
varcleanup();
return result;