Limit bits-per-feature to eight
authorBehdad Esfahbod <behdad@behdad.org>
Tue, 9 Aug 2016 00:28:54 +0000 (17:28 -0700)
committerBehdad Esfahbod <behdad@behdad.org>
Tue, 9 Aug 2016 00:29:30 +0000 (17:29 -0700)
Limits number of alternatives per glyph per feature to 255, so be it.
That's better than possibly breaking shaping because of one bad feature
value.

src/hb-ot-map.cc

index 35550af..17e3f40 100644 (file)
@@ -193,7 +193,8 @@ hb_ot_map_builder_t::compile (hb_ot_map_t &m)
       /* Uses the global bit */
       bits_needed = 0;
     else
-      bits_needed = _hb_bit_storage (info->max_value);
+      /* Limit to 8 bits per feature. */
+      bits_needed = MIN(8u, _hb_bit_storage (info->max_value));
 
     if (!info->max_value || next_bit + bits_needed > 8 * sizeof (hb_mask_t))
       continue; /* Feature disabled, or not enough bits. */