From 2ea71ccd3339e20bfb1900a85162965f39f8e619 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Wed, 29 Oct 2025 13:03:47 +0100 Subject: 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 --- src/zencore/commandline.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/zencore/commandline.cpp') 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& 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) -- cgit v1.2.3