From 0c70bc7f3286ea0c04164f110a6d2caac805812c Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 24 Nov 2022 11:48:48 -0700 Subject: [PATCH] [skippy-iter] Fix two logic errors First, a signed underflow. Second, a wrong condition. Both were introduced in 42681bdb55a75520d4ac194302fe936d1ce3cb34 --- src/hb-ot-layout-gsubgpos.hh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh index 6f1c614eb..5529ccbb2 100644 --- a/src/hb-ot-layout-gsubgpos.hh +++ b/src/hb-ot-layout-gsubgpos.hh @@ -537,10 +537,10 @@ struct hb_ot_apply_context_t : assert (num_items > 0); /* The alternate condition below is faster at string boundaries, * but produces subpar "unsafe-to-concat" values. */ - unsigned stop = end - num_items; + signed stop = (signed) end - (signed) num_items; if (c->buffer->flags & HB_BUFFER_FLAG_PRODUCE_UNSAFE_TO_CONCAT) - stop = end - 1; - while (idx < stop) + stop = (signed) end - 1; + while ((signed) idx < stop) { idx++; hb_glyph_info_t &info = c->buffer->info[idx]; @@ -575,7 +575,7 @@ struct hb_ot_apply_context_t : assert (num_items > 0); /* The alternate condition below is faster at string boundaries, * but produces subpar "unsafe-to-concat" values. */ - unsigned stop = 1 - num_items; + unsigned stop = num_items - 1; if (c->buffer->flags & HB_BUFFER_FLAG_PRODUCE_UNSAFE_TO_CONCAT) stop = 1 - 1; while (idx > stop)