Opened 6 years ago
Closed 6 years ago
#10217 closed defect (fixed)
Possible memory leak for Image::writePNG
|Reported by:||dafioram||Owned by:||csnover|
==26769== 344 bytes in 1 blocks are definitely lost in loss record 2,337 of 2,409 ==26769== at 0x4C2DB2F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==26769== by 0x5D2BEE2: png_create_info_struct (in /usr/lib/x86_64-linux-gnu/libpng16.so.16.28.0) ==26769== by 0x2A20B7: Image::writePNG(Common::WriteStream&, Graphics::Surface const&, bool) (png.cpp:290) ==26769== by 0x2703D6: SurfaceSdlGraphicsManager::saveScreenshot(char const*) (surfacesdl-graphics.cpp:1434) ==26769== by 0x27466A: SurfaceSdlGraphicsManager::notifyEvent(Common::Event const&) (surfacesdl-graphics.cpp:2666) ==26769== by 0x3AF1D1: Common::EventDispatcher::dispatchEvent(Common::Event const&) (EventDispatcher.cpp:144) ==26769== by 0x3AEC08: Common::EventDispatcher::dispatch() (EventDispatcher.cpp:61) ==26769== by 0x25D9A8: DefaultEventManager::pollEvent(Common::Event&) (default-events.cpp:93) ==26769== by 0x1AA8A0: Mohawk::MohawkEngine_Riven::doFrame() (riven.cpp:208) ==26769== by 0x1AA7EF: Mohawk::MohawkEngine_Riven::run() (riven.cpp:196) ==26769== by 0x1643D8: runGame(PluginSubclass<MetaEngine> const*, OSystem&, Common::String const&) (main.cpp:263) ==26769== by 0x1655F7: scummvm_main (main.cpp:529)
Change History (7)
comment:1 by , 6 years ago
|Summary:||MOHAWK: Riven: Possible memory leak for doFrame → Possible memory leak for Image::writePNG|
comment:2 by , 6 years ago
|Component:||Engine: Mohawk → --Other--|
comment:3 by , 6 years ago
comment:4 by , 6 years ago
loadStream doesn't use
endInfo either. It could be used by passing it to
png_read_end, but this isn't done.
comment:5 by , 6 years ago
It looks like it is still needed to destroy the read structure, line 242,
png_destroy_read_struct(&pngPtr, &infoPtr, &endInfo);
I don't know what adding it to
png_read_end would do,
png_read_end is currently passing in NULL and
endInfo isn't NULL, line 126.
comment:6 by , 6 years ago
Fixed by PR1028.
comment:7 by , 6 years ago
|Status:||new → closed|
Thanks for your help finding and fixing this! A patch for this issue has been added in commit 194984de2f8deca747b20e646cda9d54705f1723 and will be available in daily builds 1.10.0git-4974 and higher.
I was originally thinking adding a
after line 317 would make sense. But it looks like it may make the most sense to just remove:
from Image::writePNG. I think the endInfo creation in writePNG is in there because it was copied from PNGDecoder::loadStream which uses endInfo as apart of png_destroy_read_struct(&pngPtr, &infoPtr, &endInfo); in line 242. Since endInfo is not used in writePNG it can probably be removed.