Browse Source

text-freetype2: Fix undefined behavior for alpha > 127

Found via UBSan, actual (sample) error:
"plugins/text-freetype2/text-functionality.c:284:26: runtime error: left
shift of 194 by 24 places cannot be represented in type 'int'"
Palana 10 years ago
parent
commit
78ad3ec132
1 changed files with 1 additions and 1 deletions
  1. 1 1
      plugins/text-freetype2/text-functionality.c

+ 1 - 1
plugins/text-freetype2/text-functionality.c

@@ -281,7 +281,7 @@ void cache_glyphs(struct ft2_source *srcdata, wchar_t *cache_glyphs)
 			for (uint32_t x = 0; x < g_w; x++) {
 				alpha = slot->bitmap.buffer[glyph_pos];
 				srcdata->texbuf[buf_pos] =
-					0x00FFFFFF ^ (alpha << 24);
+					0x00FFFFFF ^ ((uint32_t)alpha << 24);
 			}
 		}