diff options
author | Strangerke | 2014-05-25 18:11:14 +0200 |
---|---|---|
committer | Strangerke | 2014-05-25 18:11:14 +0200 |
commit | ff569b0d2e6f4cbc33e1a9109b7198745d85bd10 (patch) | |
tree | 4e90cff5b9118fb7642273a5eaa0d3d4e57b44da /engines/cine | |
parent | 58fcb43c192eb424897a89dd18ea4788e83deb3f (diff) | |
download | scummvm-rg350-ff569b0d2e6f4cbc33e1a9109b7198745d85bd10.tar.gz scummvm-rg350-ff569b0d2e6f4cbc33e1a9109b7198745d85bd10.tar.bz2 scummvm-rg350-ff569b0d2e6f4cbc33e1a9109b7198745d85bd10.zip |
CINE: Add a safeguard to avoid a divide by zero in Palette::save()
Diffstat (limited to 'engines/cine')
-rw-r--r-- | engines/cine/pal.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/engines/cine/pal.cpp b/engines/cine/pal.cpp index f3985c691e..18f260cab7 100644 --- a/engines/cine/pal.cpp +++ b/engines/cine/pal.cpp @@ -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); |