Bug 488840 – harfbuzz: protect against ligid overflow
authorBehdad Esfahbod <behdad@gnome.org>
Sun, 21 Oct 2007 18:17:02 +0000 (18:17 +0000)
committerBehdad Esfahbod <behdad@src.gnome.org>
Sun, 21 Oct 2007 18:17:02 +0000 (18:17 +0000)
2007-10-21  Behdad Esfahbod  <behdad@gnome.org>

        Bug 488840 – harfbuzz: protect against ligid overflow

        * pango/opentype/harfbuzz-buffer.c (_hb_buffer_allocate_ligid):
        Never return zero, even in case of overflow.

        * pango/opentype/harfbuzz-impl.h: Define dummy HB_LIKELY() and
        HB_UNLIKELY(), to be filled later.

src/harfbuzz-buffer.c
src/harfbuzz-impl.h

index 8f9539a..4b25a5f 100644 (file)
@@ -356,5 +356,9 @@ _hb_buffer_replace_output_glyph( HB_Buffer buffer,
 HB_INTERNAL FT_UShort
 _hb_buffer_allocate_ligid( HB_Buffer buffer )
 {
-  return ++buffer->max_ligID;
+  buffer->max_ligID++;
+  if (HB_UNLIKELY (buffer->max_ligID == 0))
+    buffer->max_ligID++;
+
+  return buffer->max_ligID;
 }
index 2215d2c..dc89fa6 100644 (file)
@@ -49,6 +49,9 @@ FT_BEGIN_HEADER
 # define FT_UNUSED(arg) ((arg) = (arg))
 #endif
 
+#define HB_LIKELY(cond) (cond)
+#define HB_UNLIKELY(cond) (cond)
+
 #include "ftglue.h"
 
 #define ARRAY_LEN(Array) ((int)(sizeof (Array) / sizeof (Array)[0]))