From a5b8e7db4d4a9aca46169e2be27be5bba1cdd4bd Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 15 Mar 2021 12:46:58 -0600 Subject: [PATCH] [hangul] Improve error handling I did a review; changed some "return"s to "break"s, which should be identical. Removed one check just before "continue" because not necessary. The added error check is the actual fix. Should fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=31755 --- src/hb-ot-shape-complex-hangul.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/hb-ot-shape-complex-hangul.cc b/src/hb-ot-shape-complex-hangul.cc index 9878d1f42..533e928dc 100644 --- a/src/hb-ot-shape-complex-hangul.cc +++ b/src/hb-ot-shape-complex-hangul.cc @@ -274,8 +274,6 @@ preprocess_text_hangul (const hb_ot_shape_plan_t *plan HB_UNUSED, if (font->has_glyph (s)) { buffer->replace_glyphs (t ? 3 : 2, 1, &s); - if (unlikely (!buffer->successful)) - return; end = start + 1; continue; } @@ -298,6 +296,8 @@ preprocess_text_hangul (const hb_ot_shape_plan_t *plan HB_UNUSED, } else end = start + 2; + if (unlikely (!buffer->successful)) + break; if (buffer->cluster_level == HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES) buffer->merge_out_clusters (start, end); continue; @@ -325,7 +325,7 @@ preprocess_text_hangul (const hb_ot_shape_plan_t *plan HB_UNUSED, { buffer->replace_glyphs (2, 1, &new_s); if (unlikely (!buffer->successful)) - return; + break; end = start + 1; continue; } @@ -359,9 +359,8 @@ preprocess_text_hangul (const hb_ot_shape_plan_t *plan HB_UNUSED, buffer->next_glyph (); s_len++; } - if (unlikely (!buffer->successful)) - return; + break; /* We decomposed S: apply jamo features to the individual glyphs * that are now in buffer->out_info.