GBA: Do not put decoded image on the stack
Jeffrey Pfau jeffrey@endrift.com
Thu, 27 Nov 2014 11:18:22 -0800
1 files changed,
4 insertions(+),
2 deletions(-)
jump to
M
src/gba/gba-serialize.c
→
src/gba/gba-serialize.c
@@ -153,15 +153,17 @@ if (!png || !info || !end) {
PNGReadClose(png, info, end); return false; } - uint32_t pixels[VIDEO_HORIZONTAL_PIXELS * VIDEO_VERTICAL_PIXELS * 4]; + uint32_t* pixels = malloc(VIDEO_HORIZONTAL_PIXELS * VIDEO_VERTICAL_PIXELS * 4); PNGInstallChunkHandler(png, gba, _loadPNGChunkHandler, "gbAs"); PNGReadHeader(png, info); - PNGReadPixels(png, info, &pixels, VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS, VIDEO_HORIZONTAL_PIXELS); + PNGReadPixels(png, info, pixels, VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS, VIDEO_HORIZONTAL_PIXELS); PNGReadFooter(png, end); PNGReadClose(png, info, end); gba->video.renderer->putPixels(gba->video.renderer, VIDEO_HORIZONTAL_PIXELS, pixels); GBASyncPostFrame(gba->sync); + + free(pixels); return true; } #endif