From 49ab0eb6e9eaadec8e34124df9ac859576418d2d Mon Sep 17 00:00:00 2001 From: helixhorned Date: Fri, 20 Jul 2012 21:57:56 +0000 Subject: [PATCH] PNG screenshots: fix oob read of malloc'd mem on Windows. These could manifest themselves as garbage lines on the bottom and happened because of the ydim vs. bytesperline discrepancy again. git-svn-id: https://svn.eduke32.com/eduke32@2844 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/engine.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index 5cea6f9f5..673895aee 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -15964,8 +15964,8 @@ static int32_t screencapture_png(const char *filename, char inverseit, const cha begindrawing(); //{{{ if (palette) { - buf = (png_bytep)png_malloc(png_ptr, xdim*ydim); - Bmemcpy(buf, (char *)frameplace, xdim*ydim); + buf = (png_bytep)png_malloc(png_ptr, bytesperline*ydim); + Bmemcpy(buf, (char *)frameplace, bytesperline*ydim); } # ifdef USE_OPENGL else @@ -15977,6 +15977,7 @@ static int32_t screencapture_png(const char *filename, char inverseit, const cha enddrawing(); //}}} rowptrs = (png_bytepp)png_malloc(png_ptr, ydim*sizeof(png_bytep)); + if (!palette) { for (i=0; i