2013-07-30 Behdad Esfahbod <behdad@google.com> Prevent division by zero by a transparent color. * src/base/ftbitmap.c (ft_gray_for_premultiplied_srgb_bgra): Return 0 immediately, when alpha channel is zero.
diff --git a/ChangeLog b/ChangeLog
index c15bda3..47453ce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2013-07-30 Behdad Esfahbod <behdad@google.com>
+
+ Prevent division by zero by a transparent color.
+
+ * src/base/ftbitmap.c (ft_gray_for_premultiplied_srgb_bgra):
+ Return 0 immediately, when alpha channel is zero.
+
2013-07-25 Behdad Esfahbod <behdad@google.com>
Add FT_FACE_FLAG_COLOR and FT_HAS_COLOR.
diff --git a/src/base/ftbitmap.c b/src/base/ftbitmap.c
index 975818e..d876108 100644
--- a/src/base/ftbitmap.c
+++ b/src/base/ftbitmap.c
@@ -385,6 +385,10 @@
FT_Long l;
+ /* Short-circuit transparent color to avoid div-by-zero. */
+ if (!a)
+ return 0;
+
/*
* Luminosity for sRGB is defined using ~0.2126,0.7152,0.0722
* coefficients for RGB channels *on the linear colors*.