aboutsummaryrefslogtreecommitdiff
path: root/src/zencore/commandline.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2025-10-29 13:03:47 +0100
committerGitHub Enterprise <[email protected]>2025-10-29 13:03:47 +0100
commit2ea71ccd3339e20bfb1900a85162965f39f8e619 (patch)
treeb5d3da914be1f0c40fbed62bd2a4a23a19615541 /src/zencore/commandline.cpp
parentmake sure OpenProcessCache is initialized before use (#618) (diff)
downloadzen-2ea71ccd3339e20bfb1900a85162965f39f8e619.tar.xz
zen-2ea71ccd3339e20bfb1900a85162965f39f8e619.zip
fix minor memory leak in command line parsing (#619)
when calling `getdelim` in a loop, it will return an allocated block of memory even if it is at EOF
Diffstat (limited to 'src/zencore/commandline.cpp')
-rw-r--r--src/zencore/commandline.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/zencore/commandline.cpp b/src/zencore/commandline.cpp
index c801bf151..0cdccf986 100644
--- a/src/zencore/commandline.cpp
+++ b/src/zencore/commandline.cpp
@@ -48,6 +48,11 @@ IterateCommandlineArgs(std::function<void(const std::string_view& Arg)>& Process
ArgV[ArgC++] = Arg;
Arg = nullptr; // getdelim will allocate buffer for next Arg
}
+ if (Arg)
+ {
+ // getdelim allocated one last arg buffer that we didn't use
+ free(Arg);
+ }
fclose(CmdLineFile);
if (ArgC > 1)