mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-17 23:44:22 +00:00
CINE: Add a safeguard to avoid a divide by zero in Palette::save()
This commit is contained in:
parent
58fcb43c19
commit
ff569b0d2e
@ -332,9 +332,9 @@ byte *Palette::save(byte *buf, const uint size, const Graphics::PixelFormat form
|
||||
|
||||
// Save the palette to the output in the specified format
|
||||
for (uint i = firstIndex; i < firstIndex + numColors; i++) {
|
||||
const uint r = (_colors[i].r * rNewMax) / rOrigMax;
|
||||
const uint g = (_colors[i].g * gNewMax) / gOrigMax;
|
||||
const uint b = (_colors[i].b * bNewMax) / bOrigMax;
|
||||
const uint r = (_colors[i].r * rNewMax) / (rOrigMax == 0 ? 1 : rOrigMax);
|
||||
const uint g = (_colors[i].g * gNewMax) / (gOrigMax == 0 ? 1 : gOrigMax);
|
||||
const uint b = (_colors[i].b * bNewMax) / (bOrigMax == 0 ? 1 : bOrigMax);
|
||||
|
||||
buf[i * format.bytesPerPixel + rBytePos] |= r << (format.rShift % 8);
|
||||
buf[i * format.bytesPerPixel + gBytePos] |= g << (format.gShift % 8);
|
||||
|
Loading…
x
Reference in New Issue
Block a user