ref: 7e83f06804c3c4d9c740c857b913595939490e80
parent: 3889cb2faa1f5520d6b26d3eb56b4f83525e4e68
author: Alexei Podtelezhnikov <[email protected]>
date: Tue Oct 14 19:03:56 EDT 2014
[truetype] Limit delta shift range. The legal range for delta shift is zero through six. Negative values are illegal according to https://developer.apple.com/fonts/TrueType-Reference-Manual/RM04/Chap4.html#delta%20shift * src/truetype/ttobjs.h (delta_shift, delta_base): Make unsigned. * src/truetype/ttinterp.h (DO_SDS): Throw an error if delta_shift out of range. (Ins_DELTAP, Ins_DELTAC): Optimize for legal delta_shift.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2014-10-14 Alexei Podtelezhnikov <[email protected]>
+
+ [truetype] Limit delta shift range.
+
+ The legal range for delta shift is zero through six. Negative values
+ are illegal according to
+ https://developer.apple.com/fonts/TrueType-Reference-Manual/RM04/Chap4.html#delta%20shift
+
+ * src/truetype/ttobjs.h (delta_shift, delta_base): Make unsigned.
+ * src/truetype/ttinterp.h (DO_SDS): Throw an error if delta_shift
+ out of range.
+ (Ins_DELTAP, Ins_DELTAC): Optimize for legal delta_shift.
+
2014-10-14 David Weiß <[email protected]>
[build] Better optimization settings for vc2010 solution file.
--- a/src/truetype/ttinterp.c
+++ b/src/truetype/ttinterp.c
@@ -3081,12 +3081,15 @@
CUR.GS.auto_flip = FALSE;
-#define DO_SDB \
- CUR.GS.delta_base = (FT_Short)args[0];
+#define DO_SDB \
+ CUR.GS.delta_base = (FT_UShort)args[0];
-#define DO_SDS \
- CUR.GS.delta_shift = (FT_Short)args[0];
+#define DO_SDS \
+ if ( (FT_ULong)args[0] > 6UL ) \
+ CUR.error = FT_THROW( Bad_Argument ); \
+ else \
+ CUR.GS.delta_shift = (FT_UShort)args[0];
#define DO_MD /* nothing */
@@ -7577,7 +7580,7 @@
B = ( (FT_ULong)B & 0xF ) - 8;
if ( B >= 0 )
B++;
- B = B * 64 / ( 1L << CUR.GS.delta_shift );
+ B *= 1L << ( 6 - CUR.GS.delta_shift );
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
@@ -7747,7 +7750,7 @@
B = ( (FT_ULong)B & 0xF ) - 8;
if ( B >= 0 )
B++;
- B = B * 64 / ( 1L << CUR.GS.delta_shift );
+ B *= 1L << ( 6 - CUR.GS.delta_shift );
CUR_Func_move_cvt( A, B );
}
--- a/src/truetype/ttobjs.h
+++ b/src/truetype/ttobjs.h
@@ -95,8 +95,8 @@
FT_F26Dot6 control_value_cutin;
FT_F26Dot6 single_width_cutin;
FT_F26Dot6 single_width_value;
- FT_Short delta_base;
- FT_Short delta_shift;
+ FT_UShort delta_base;
+ FT_UShort delta_shift;
FT_Byte instruct_control;
/* According to Greg Hitchcock from Microsoft, the `scan_control' */