GRAPHICS: Fix memory overrun blitting from paletted surfaces

This commit is contained in:
Paul Gilbert 2020-05-08 18:31:46 -07:00
parent 0f96d7b776
commit bb405565b7

View file

@ -244,8 +244,7 @@ void ManagedSurface::blitFromInner(const Surface &src, const Common::Rect &srcRe
for (int x = 0; x < srcBounds.width(); ++x,
srcP += src.format.bytesPerPixel,
destP += format.bytesPerPixel) {
src.format.colorToARGB(src.format.bytesPerPixel == 2 ? *(const uint16 *)srcP : *(const uint32 *)srcP,
aSrc, rSrc, gSrc, bSrc);
if (src.format.bytesPerPixel == 1) {
// Get the palette color
const uint32 col = palette[*srcP];
@ -255,8 +254,9 @@ void ManagedSurface::blitFromInner(const Surface &src, const Common::Rect &srcRe
aSrc = (col >> 24) & 0xff;
} else {
// Use the src's pixel format to split up the source pixel
format.colorToRGB(format.bytesPerPixel == 2 ? *(const uint16 *)destP : *(const uint32 *)destP,
rDest, gDest, bDest);
src.format.colorToARGB(src.format.bytesPerPixel == 2
? *(const uint16 *)srcP : *(const uint32 *)srcP,
aSrc, rSrc, gSrc, bSrc);
}
if (aSrc == 0) {