From 4063de40705c2b21e092f2a275182b0f41070b15 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 18 Aug 2013 18:21:19 +0200 Subject: GRAPHICS: Add some paranoia asserts in JPEGDecoder. --- graphics/decoders/jpeg.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'graphics/decoders') diff --git a/graphics/decoders/jpeg.cpp b/graphics/decoders/jpeg.cpp index ba6292bbbd..c858884095 100644 --- a/graphics/decoders/jpeg.cpp +++ b/graphics/decoders/jpeg.cpp @@ -214,7 +214,9 @@ bool JPEGDecoder::loadStream(Common::SeekableReadStream &stream) { } // Allocate buffer for one scanline + assert(cinfo.output_components == 3); JDIMENSION pitch = cinfo.output_width * cinfo.output_components; + assert(_surface.pitch >= pitch); JSAMPARRAY buffer = (*cinfo.mem->alloc_sarray)((j_common_ptr)&cinfo, JPOOL_IMAGE, pitch, 1); // Go through the image data scanline by scanline @@ -246,7 +248,7 @@ bool JPEGDecoder::loadStream(Common::SeekableReadStream &stream) { } break; case kColorSpaceYUV: - memcpy(dst, src, _surface.pitch); + memcpy(dst, src, pitch); break; } } -- cgit v1.2.3