[Scummvm-cvs-logs] scummvm master -> ff569b0d2e6f4cbc33e1a9109b7198745d85bd10

Strangerke Strangerke at scummvm.org
Sun May 25 18:12:41 CEST 2014


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
ff569b0d2e CINE: Add a safeguard to avoid a divide by zero in Palette::save()


Commit: ff569b0d2e6f4cbc33e1a9109b7198745d85bd10
    https://github.com/scummvm/scummvm/commit/ff569b0d2e6f4cbc33e1a9109b7198745d85bd10
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-25T18:11:14+02:00

Commit Message:
CINE: Add a safeguard to avoid a divide by zero in Palette::save()

Changed paths:
    engines/cine/pal.cpp



diff --git a/engines/cine/pal.cpp b/engines/cine/pal.cpp
index f3985c6..18f260c 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);






More information about the Scummvm-git-logs mailing list