[Fontconfig] fontconfig: Branch 'master'

Behdad Esfahbod behdad at kemper.freedesktop.org
Tue Jan 9 10:03:37 UTC 2018


 src/fccharset.c  |    6 +++---
 src/fcfreetype.c |    4 ++--
 src/ftglue.h     |   12 ++++++------
 3 files changed, 11 insertions(+), 11 deletions(-)

New commits:
commit fd2ad1147ad9565841372e56e6bb939c0f843ac5
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Jan 9 10:54:55 2018 +0100

    Fix undefined-behavior signed shifts

diff --git a/src/fccharset.c b/src/fccharset.c
index 69fbf66..114f948 100644
--- a/src/fccharset.c
+++ b/src/fccharset.c
@@ -274,7 +274,7 @@ FcCharSetAddChar (FcCharSet *fcs, FcChar32 ucs4)
     if (!leaf)
 	return FcFalse;
     b = &leaf->map[(ucs4 & 0xff) >> 5];
-    *b |= (1 << (ucs4 & 0x1f));
+    *b |= (1U << (ucs4 & 0x1f));
     return FcTrue;
 }
 
@@ -290,7 +290,7 @@ FcCharSetDelChar (FcCharSet *fcs, FcChar32 ucs4)
     if (!leaf)
 	return FcTrue;
     b = &leaf->map[(ucs4 & 0xff) >> 5];
-    *b &= ~(1 << (ucs4 & 0x1f));
+    *b &= ~(1U << (ucs4 & 0x1f));
     /* We don't bother removing the leaf if it's empty */
     return FcTrue;
 }
@@ -594,7 +594,7 @@ FcCharSetHasChar (const FcCharSet *fcs, FcChar32 ucs4)
     leaf = FcCharSetFindLeaf (fcs, ucs4);
     if (!leaf)
 	return FcFalse;
-    return (leaf->map[(ucs4 & 0xff) >> 5] & (1 << (ucs4 & 0x1f))) != 0;
+    return (leaf->map[(ucs4 & 0xff) >> 5] & (1U << (ucs4 & 0x1f))) != 0;
 }
 
 static FcChar32
diff --git a/src/fcfreetype.c b/src/fcfreetype.c
index 4d076b7..49fb39f 100644
--- a/src/fcfreetype.c
+++ b/src/fcfreetype.c
@@ -1670,7 +1670,7 @@ FcFreeTypeQueryFaceInternal (const FT_Face  face,
 		bits = os2->ulCodePageRange2;
 		bit = FcCodePageRange[i].bit - 32;
 	    }
-	    if (bits & (1 << bit))
+	    if (bits & (1U << bit))
 	    {
 		/*
 		 * If the font advertises support for multiple
@@ -2378,7 +2378,7 @@ FcFreeTypeCharSet (FT_Face face, FcBlanks *blanks FC_UNUSED)
 			goto bail;
 		}
 		off = ucs4 & 0xff;
-		leaf->map[off >> 5] |= (1 << (off & 0x1f));
+		leaf->map[off >> 5] |= (1U << (off & 0x1f));
 	    }
 
 	    ucs4 = FT_Get_Next_Char (face, ucs4, &glyph);
diff --git a/src/ftglue.h b/src/ftglue.h
index e0fd171..650ee28 100644
--- a/src/ftglue.h
+++ b/src/ftglue.h
@@ -69,14 +69,14 @@ FT_BEGIN_HEADER
 
 #define  GET_Byte()      (*stream->cursor++)
 #define  GET_Short()     (stream->cursor += 2, (FT_Short)( \
-				(*(((FT_Byte*)stream->cursor)-2) << 8) | \
-				 *(((FT_Byte*)stream->cursor)-1) \
+				((FT_ULong)*(((FT_Byte*)stream->cursor)-2) << 8) | \
+				 (FT_ULong)*(((FT_Byte*)stream->cursor)-1) \
 			 ))
 #define  GET_Long()      (stream->cursor += 4, (FT_Long)( \
-				(*(((FT_Byte*)stream->cursor)-4) << 24) | \
-				(*(((FT_Byte*)stream->cursor)-3) << 16) | \
-				(*(((FT_Byte*)stream->cursor)-2) << 8) | \
-				 *(((FT_Byte*)stream->cursor)-1) \
+				((FT_ULong)*(((FT_Byte*)stream->cursor)-4) << 24) | \
+				((FT_ULong)*(((FT_Byte*)stream->cursor)-3) << 16) | \
+				((FT_ULong)*(((FT_Byte*)stream->cursor)-2) << 8) | \
+				 (FT_ULong)*(((FT_Byte*)stream->cursor)-1) \
 			 ))
 
 #define  GET_Char()      ((FT_Char)GET_Byte())


More information about the Fontconfig mailing list