summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Dennedy <dan@dennedy.org>2014-11-11 02:15:24 (GMT)
committer Dan Dennedy <dan@dennedy.org>2014-11-11 02:15:24 (GMT)
commit75e89401ac9c3f280acfc6dc6bc61491eab97b49 (patch)
tree3832e39b0b40d8594b3c1486c22b269045826e1e
parentc607f6a635024332d799f9761146e032bb4eee13 (diff)
Fix possible divide by zero.
-rw-r--r--include/frei0r_cairo.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/include/frei0r_cairo.h b/include/frei0r_cairo.h
index bd1b28d..c4e9eaf 100644
--- a/include/frei0r_cairo.h
+++ b/include/frei0r_cairo.h
@@ -251,9 +251,11 @@ void frei0r_cairo_unpremultiply_rgba (unsigned char *rgba, int pixels)
int i = pixels + 1;
while ( --i ) {
register unsigned char a = rgba[3];
- rgba[0] = ( rgba[0] << 8 ) / a;
- rgba[1] = ( rgba[1] << 8 ) / a;
- rgba[2] = ( rgba[2] << 8 ) / a;
+ if (a != 0) {
+ rgba[0] = ( rgba[0] << 8 ) / a;
+ rgba[1] = ( rgba[1] << 8 ) / a;
+ rgba[2] = ( rgba[2] << 8 ) / a;
+ }
rgba += 4;
}
}