aboutsummaryrefslogtreecommitdiff
path: root/graphics/pict.cpp
diff options
context:
space:
mode:
authorMatthew Hoops2011-12-19 15:20:50 -0500
committerMatthew Hoops2011-12-19 15:21:35 -0500
commitbdf14ed5985a318c3e07477d7bd108500e2c5043 (patch)
treea357b2207f649cd32341295933d6b470df5bc1d2 /graphics/pict.cpp
parent96face8ba870c09b7f7ce6847165bd2aed0d3e77 (diff)
downloadscummvm-rg350-bdf14ed5985a318c3e07477d7bd108500e2c5043.tar.gz
scummvm-rg350-bdf14ed5985a318c3e07477d7bd108500e2c5043.tar.bz2
scummvm-rg350-bdf14ed5985a318c3e07477d7bd108500e2c5043.zip
GRAPHICS: Fix PICT lines with large pitches
Diffstat (limited to 'graphics/pict.cpp')
-rw-r--r--graphics/pict.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/graphics/pict.cpp b/graphics/pict.cpp
index dcd0df8e10..ef262931b2 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++) {