From 13b2b963848ada169c2fe3d3669fbc1c337f7fe7 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 21 Oct 2007 18:17:02 +0000 Subject: [PATCH] =?UTF-8?q?Bug=20488840=20=E2=80=93=20harfbuzz:=20protect?= =?UTF-8?q?=20against=20ligid=20overflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2007-10-21 Behdad Esfahbod 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 | 6 +++++- src/harfbuzz-impl.h | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/harfbuzz-buffer.c b/src/harfbuzz-buffer.c index 8f9539a9d..4b25a5f12 100644 --- a/src/harfbuzz-buffer.c +++ b/src/harfbuzz-buffer.c @@ -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; } diff --git a/src/harfbuzz-impl.h b/src/harfbuzz-impl.h index 2215d2c40..dc89fa679 100644 --- a/src/harfbuzz-impl.h +++ b/src/harfbuzz-impl.h @@ -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]))