[base] Avoid undefined behaviour in lcd filtering code (#53727). * src/base/ftlcdfil.c (ft_lcd_filter_fir, _ft_lcd_filter_legacy): Ensure `height > 0'.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
diff --git a/ChangeLog b/ChangeLog
index 690d074..cd8b153 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2018-04-24 Ben Wagner <bungeman@google.com>
+
+ [base] Avoid undefined behaviour in lcd filtering code (#53727).
+
+ * src/base/ftlcdfil.c (ft_lcd_filter_fir, _ft_lcd_filter_legacy):
+ Ensure `height > 0'.
+
2018-04-22 Werner Lemberg <wl@gnu.org>
* src/base/ftoutln.c (FT_Outline_Decompose): Improve error tracing.
diff --git a/src/base/ftlcdfil.c b/src/base/ftlcdfil.c
index 5c38911..8d314df 100644
--- a/src/base/ftlcdfil.c
+++ b/src/base/ftlcdfil.c
@@ -77,7 +77,7 @@
/* take care of bitmap flow */
- if ( pitch > 0 )
+ if ( pitch > 0 && height > 0 )
origin += pitch * (FT_Int)( height - 1 );
/* horizontal in-place FIR filter */
@@ -192,7 +192,7 @@
/* take care of bitmap flow */
- if ( pitch > 0 )
+ if ( pitch > 0 && height > 0 )
origin += pitch * (FT_Int)( height - 1 );
/* horizontal in-place intra-pixel filter */