diff options
Diffstat (limited to 'graphics/pict.cpp')
-rw-r--r-- | graphics/pict.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/graphics/pict.cpp b/graphics/pict.cpp index 0f4dcd463f..872f2f224a 100644 --- a/graphics/pict.cpp +++ b/graphics/pict.cpp @@ -338,10 +338,9 @@ void PictDecoder::unpackBitsRect(Common::SeekableReadStream *stream, bool hasPal _outputSurface = new Graphics::Surface(); _outputSurface->create(width, height, (bytesPerPixel == 1) ? PixelFormat::createFormatCLUT8() : _pixelFormat); - // Create an temporary buffer, but allocate a bit more than we need to avoid overflow - // (align it to the next highest two-byte packed boundary, which may be more unpacked, - // as m68k and therefore QuickDraw is word-aligned) - byte *buffer = new byte[width * height * bytesPerPixel + (8 * 2 / packBitsData.pixMap.pixelSize)]; + // Ensure we have enough space in the buffer to hold an entire line's worth of pixels + uint32 lineSize = MAX<int>(width * bytesPerPixel + (8 * 2 / packBitsData.pixMap.pixelSize), packBitsData.pixMap.rowBytes); + byte *buffer = new byte[lineSize * height]; // Read in amount of data per row for (uint16 i = 0; i < packBitsData.pixMap.bounds.height(); i++) { @@ -467,7 +466,6 @@ void PictDecoder::skipBitsRect(Common::SeekableReadStream *stream, bool hasPalet stream->readUint16BE(); uint16 packType; - uint16 pixelSize; // Top two bits signify PixMap vs BitMap if (rowBytes & 0xC000) { @@ -475,7 +473,7 @@ void PictDecoder::skipBitsRect(Common::SeekableReadStream *stream, bool hasPalet stream->readUint16BE(); packType = stream->readUint16BE(); stream->skip(14); - pixelSize = stream->readUint16BE(); + stream->readUint16BE(); // pixelSize stream->skip(16); if (hasPalette) { @@ -488,7 +486,6 @@ void PictDecoder::skipBitsRect(Common::SeekableReadStream *stream, bool hasPalet } else { // BitMap packType = 0; - pixelSize = 1; } stream->skip(18); |