IMAGE: Check the output surface bounds when writing QT encoded PICT images

This commit is contained in:
Bastien Bouclet 2018-09-13 22:53:37 +02:00
parent f0f02c4a3f
commit 360e1e97c9

View File

@ -577,9 +577,14 @@ void PICTDecoder::decodeCompressedQuickTime(Common::SeekableReadStream &stream)
_outputSurface = new Graphics::Surface();
_outputSurface->create(_imageRect.width(), _imageRect.height(), surface->format);
}
assert(_outputSurface->format == surface->format);
for (uint16 y = 0; y < surface->h; y++)
memcpy(_outputSurface->getBasePtr(0 + xOffset, y + yOffset), surface->getBasePtr(0, y), surface->w * surface->format.bytesPerPixel);
Common::Rect outputRect(surface->w, surface->h);
outputRect.translate(xOffset, yOffset);
outputRect.clip(_imageRect);
for (uint16 y = 0; y < outputRect.height(); y++)
memcpy(_outputSurface->getBasePtr(outputRect.left, y + outputRect.top), surface->getBasePtr(0, y), outputRect.width() * surface->format.bytesPerPixel);
stream.seek(startPos + dataSize);
delete codec;