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
This commit is contained in:
helixhorned 2012-07-20 21:57:56 +00:00
parent 2a2f56f510
commit 49ab0eb6e9
1 changed files with 3 additions and 2 deletions

View File

@ -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<ydim; i++)