Resolve strdup memory leak with GetPathBaseName#1106
Conversation
…Name and ModuleNameAndOffset::GetPathBaseName
stem() strips the final extension, changing behavior from the original POSIX basename() and the Windows branch (which both keep the extension). This would mangle module names like libc.so.6 -> libc.so and break module-name matching. filename() preserves the full final component. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Thanks for fixing the I pushed a one-line follow-up to your branch (627f0fa) changing
I also added the explicit The extra includes and the leak fix itself look good. One optional suggestion: a small unit test for |
|
Thanks! @SmoothHacker |
Whenever
DebugModule::GetPathBaseNameandModuleNameAndOffset::GetPathBaseNameis called a memory leak the size of the c string version of the path parameter is created because ofstrdup(). The fix involves using std::filesystem. We create a std::filesystem::path object and then return the steam of that path.