Author: stippi Date: Sun Mar 14 23:23:38 2010 New Revision: 311 URL: http://mmlr.dyndns.org/changeset/311 Log: * Fixed a possible division by zero when demultiplying colors. * Moved a comment into it's appropriate scope. Modified: webkit/trunk/WebCore/platform/graphics/haiku/ImageBufferHaiku.cpp Modified: webkit/trunk/WebCore/platform/graphics/haiku/ImageBufferHaiku.cpp ============================================================================== --- webkit/trunk/WebCore/platform/graphics/haiku/ImageBufferHaiku.cpp Sun Mar 14 10:27:39 2010 (r310) +++ webkit/trunk/WebCore/platform/graphics/haiku/ImageBufferHaiku.cpp Sun Mar 14 23:23:38 2010 (r311) @@ -175,17 +175,24 @@ unsigned rows, unsigned columns, bool premultiplied) { - // Internal storage is not pre-multiplied, de-multiply source data. if (premultiplied) { + // Internal storage is not pre-multiplied, de-multiply source data. for (unsigned y = 0; y < rows; y++) { const uint8* s = sourceRows; uint8* d = destRows; for (unsigned x = 0; x < columns; x++) { // RGBA -> BGRA or BGRA -> RGBA - d[0] = static_cast<uint16>(s[2]) * 255 / s[3]; - d[1] = static_cast<uint16>(s[1]) * 255 / s[3]; - d[2] = static_cast<uint16>(s[0]) * 255 / s[3]; - d[3] = s[3]; + if (s[3]) { + d[0] = static_cast<uint16>(s[2]) * 255 / s[3]; + d[1] = static_cast<uint16>(s[1]) * 255 / s[3]; + d[2] = static_cast<uint16>(s[0]) * 255 / s[3]; + d[3] = s[3]; + } else { + d[0] = 0; + d[1] = 0; + d[2] = 0; + d[3] = 0; + } d += 4; s += 4; }