Skip to content

Commit

Permalink
IMAGE: Check the output surface bounds when writing QT encoded PICT i…
Browse files Browse the repository at this point in the history
…mages
  • Loading branch information
bgK committed Sep 14, 2018
1 parent f0f02c4 commit 360e1e9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions image/pict.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 360e1e9

Please sign in to comment.