[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
This commit is contained in:
Behdad Esfahbod 2021-03-15 12:46:58 -06:00
parent 99767f9386
commit a5b8e7db4d
1 changed files with 4 additions and 5 deletions

View File

@ -274,8 +274,6 @@ preprocess_text_hangul (const hb_ot_shape_plan_t *plan HB_UNUSED,
if (font->has_glyph (s)) if (font->has_glyph (s))
{ {
buffer->replace_glyphs (t ? 3 : 2, 1, &s); buffer->replace_glyphs (t ? 3 : 2, 1, &s);
if (unlikely (!buffer->successful))
return;
end = start + 1; end = start + 1;
continue; continue;
} }
@ -298,6 +296,8 @@ preprocess_text_hangul (const hb_ot_shape_plan_t *plan HB_UNUSED,
} }
else else
end = start + 2; end = start + 2;
if (unlikely (!buffer->successful))
break;
if (buffer->cluster_level == HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES) if (buffer->cluster_level == HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES)
buffer->merge_out_clusters (start, end); buffer->merge_out_clusters (start, end);
continue; continue;
@ -325,7 +325,7 @@ preprocess_text_hangul (const hb_ot_shape_plan_t *plan HB_UNUSED,
{ {
buffer->replace_glyphs (2, 1, &new_s); buffer->replace_glyphs (2, 1, &new_s);
if (unlikely (!buffer->successful)) if (unlikely (!buffer->successful))
return; break;
end = start + 1; end = start + 1;
continue; continue;
} }
@ -359,9 +359,8 @@ preprocess_text_hangul (const hb_ot_shape_plan_t *plan HB_UNUSED,
buffer->next_glyph (); buffer->next_glyph ();
s_len++; s_len++;
} }
if (unlikely (!buffer->successful)) if (unlikely (!buffer->successful))
return; break;
/* We decomposed S: apply jamo features to the individual glyphs /* We decomposed S: apply jamo features to the individual glyphs
* that are now in buffer->out_info. * that are now in buffer->out_info.