openspades icon indicating copy to clipboard operation
openspades copied to clipboard

Memory leak in `ZipFileSystem`

Open yvt opened this issue 4 years ago • 0 comments

https://github.com/yvt/openspades/blob/fdba89bc143b88bc72579aed9a65b00a6909ef2e/Sources/Core/ZipFileSystem.cpp#L346-L363

In the above C(VE)++ code, ZipFileSystem::OpenForReading constructs ZipFileInputStream and stores a pointer to it in a variable named currentStream. While it might look like currentStream is properly deleted in all code paths, it's actually a member variable. currentStream->ForceCloseUnzipFile() implicitly clears it without deleting it, leaking memory.

(Thank you @Haxk20 for suggesting the use of valgrind.)

yvt avatar Sep 20 '21 13:09 yvt