summaryrefslogtreecommitdiff
path: root/include/freetype/freetype.h
diff options
context:
space:
mode:
authorWerner Lemberg <wl@gnu.org>2021-11-19 21:50:22 +0100
committerWerner Lemberg <wl@gnu.org>2021-11-20 07:58:31 +0100
commit8c8f51c55813b4f01e1a77d4fc8838c6a5fb998c (patch)
tree7083cf6eef2426a3700d5fe2e6d34de3a897b9e0 /include/freetype/freetype.h
parent9079c5d91aa87bcae223fc933b9c0ebf346b7d64 (diff)
downloadfreetype2-8c8f51c55813b4f01e1a77d4fc8838c6a5fb998c.tar.gz
Avoid undefined left-shifts.
We really have to use double casts to avoid issues with C's and C++'s signedness propagation rules in implicit casts. Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=41178 https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=41182 * include/freetype/config/public-macros.h (FT_STATIC_CAST, FT_REINTERPRET_CAST): Modify macro to take two arguments. Update all callers. (FT_STATIC_BYTE_CAST): New macro. * include/freetype/freetype.h (FT_ENC_TAG): Use `FT_STATIC_BYTE_CAST`. * include/freetype/ftimage.h (FT_IMAGE_TAG): Ditto. * include/freetype/fttypes.h (FT_MAKE_TAG): Ditto. Use `FT_Tag` for casting. * src/ftraster/ftmisc.h (FT_MAKE_TAG): Removed, no longer needed. (FT_STATIC_BYTE_CAST): New macro. * src/smooth/ftgrays.c (FT_STATIC_CAST): Replace with... (FT_STATIC_BYTE_CAST): ... this.
Diffstat (limited to 'include/freetype/freetype.h')
-rw-r--r--include/freetype/freetype.h16
1 files changed, 8 insertions, 8 deletions
diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h
index 7da4eb687..e3438f2bc 100644
--- a/include/freetype/freetype.h
+++ b/include/freetype/freetype.h
@@ -617,11 +617,11 @@ FT_BEGIN_HEADER
#ifndef FT_ENC_TAG
-#define FT_ENC_TAG( value, a, b, c, d ) \
- value = ( ( FT_STATIC_CAST( FT_Byte )(a) << 24 ) | \
- ( FT_STATIC_CAST( FT_Byte )(b) << 16 ) | \
- ( FT_STATIC_CAST( FT_Byte )(c) << 8 ) | \
- FT_STATIC_CAST( FT_Byte )(d) )
+#define FT_ENC_TAG( value, a, b, c, d ) \
+ value = ( ( FT_STATIC_BYTE_CAST( FT_UInt32, a ) << 24 ) | \
+ ( FT_STATIC_BYTE_CAST( FT_UInt32, b ) << 16 ) | \
+ ( FT_STATIC_BYTE_CAST( FT_UInt32, c ) << 8 ) | \
+ FT_STATIC_BYTE_CAST( FT_UInt32, d ) )
#endif /* FT_ENC_TAG */
@@ -3182,7 +3182,7 @@ FT_BEGIN_HEADER
* necessary to empty the cache after a mode switch to avoid false hits.
*
*/
-#define FT_LOAD_TARGET_( x ) ( FT_STATIC_CAST( FT_Int32 )( (x) & 15 ) << 16 )
+#define FT_LOAD_TARGET_( x ) ( FT_STATIC_CAST( FT_Int32, (x) & 15 ) << 16 )
#define FT_LOAD_TARGET_NORMAL FT_LOAD_TARGET_( FT_RENDER_MODE_NORMAL )
#define FT_LOAD_TARGET_LIGHT FT_LOAD_TARGET_( FT_RENDER_MODE_LIGHT )
@@ -3201,8 +3201,8 @@ FT_BEGIN_HEADER
* @FT_LOAD_TARGET_XXX value.
*
*/
-#define FT_LOAD_TARGET_MODE( x ) \
- FT_STATIC_CAST( FT_Render_Mode )( ( (x) >> 16 ) & 15 )
+#define FT_LOAD_TARGET_MODE( x ) \
+ FT_STATIC_CAST( FT_Render_Mode, ( (x) >> 16 ) & 15 )
/**************************************************************************