Commit de8f14a8e41bf5e01714539cbcd3de16d546ce6c

Werner Lemberg 2022-09-30T23:25:02

* src/psaux/pshints.c (cf2_hintmap_insertHint): Fix midpoint computation. Replace '(start + end) / 2' with 'start + (end - start) / 2' to avoid overflow. Fixes #1180.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
diff --git a/src/psaux/pshints.c b/src/psaux/pshints.c
index 991204c..6f44d0a 100644
--- a/src/psaux/pshints.c
+++ b/src/psaux/pshints.c
@@ -693,8 +693,10 @@
         CF2_Fixed  midpoint =
                      cf2_hintmap_map(
                        hintmap->initialHintMap,
-                       ADD_INT32( secondHintEdge->csCoord,
-                                  firstHintEdge->csCoord ) / 2 );
+                       ADD_INT32(
+                         firstHintEdge->csCoord,
+                         SUB_INT32 ( secondHintEdge->csCoord,
+                                     firstHintEdge->csCoord ) / 2 ) );
         CF2_Fixed  halfWidth =
                      FT_MulFix( SUB_INT32( secondHintEdge->csCoord,
                                            firstHintEdge->csCoord ) / 2,