Commit 4797b2ff22906ce4ff4e6dcee300a70f94dcc43a

Dominik Röttsches 2022-08-26T12:08:34

[sfnt] Avoid undefined shifts in `COLR` v1 color line retrieval * src/sfnt/ttcolr.c (tt_face_get_colorline_stops): Disambiguate shift behavior by using multiplication using macros from ftcalc.h. Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=50573

diff --git a/src/sfnt/ttcolr.c b/src/sfnt/ttcolr.c
index 25051a4..1277bbd 100644
--- a/src/sfnt/ttcolr.c
+++ b/src/sfnt/ttcolr.c
@@ -1575,7 +1575,7 @@
     /* Iterator points at first `ColorStop` of `ColorLine`. */
     p = iterator->p;
 
-    color_stop->stop_offset = (FT_Fixed)FT_NEXT_SHORT( p ) << 2;
+    color_stop->stop_offset = F2DOT14_TO_FIXED( FT_NEXT_SHORT( p ) );
 
     color_stop->color.palette_index = FT_NEXT_USHORT( p );
 
@@ -1600,7 +1600,7 @@
                                              item_deltas ) )
           return 0;
 
-        color_stop->stop_offset += (FT_Fixed)item_deltas[0] << 2;
+        color_stop->stop_offset += F2DOT14_TO_FIXED( item_deltas[0] );
         color_stop->color.alpha += item_deltas[1];
       }
 #else