]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tool_operate: fix minor memory-leak on early error
authorDaniel Stenberg <daniel@haxx.se>
Tue, 17 Mar 2026 12:19:25 +0000 (13:19 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 17 Mar 2026 13:52:12 +0000 (14:52 +0100)
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

src/tool_operate.c

index 6c47c1363112a7f4a1c32e64e699d01971081869..fdb7e1052f5d7eccfb2159bc2f848f6f52e6f670 100644 (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;