Fix segfault with empty buffer in hb_shape_plan_execute()

Move the empty-buffer check from hb_shape_full() to hb_shape_plan_execute().

Reported by Simon Cozens.
This commit is contained in:
Behdad Esfahbod 2015-10-02 07:25:52 +01:00
parent 432ffc47a4
commit 26ba4d1e1f
2 changed files with 7 additions and 7 deletions

View File

@ -293,8 +293,13 @@ hb_shape_plan_execute (hb_shape_plan_t *shape_plan,
num_features,
shape_plan->shaper_func);
if (unlikely (hb_object_is_inert (shape_plan) ||
hb_object_is_inert (buffer)))
if (unlikely (!buffer->len))
return true;
assert (!hb_object_is_inert (buffer));
assert (buffer->content_type == HB_BUFFER_CONTENT_TYPE_UNICODE);
if (unlikely (hb_object_is_inert (shape_plan)))
return false;
assert (shape_plan->face_unsafe == font->face);

View File

@ -371,11 +371,6 @@ hb_shape_full (hb_font_t *font,
unsigned int num_features,
const char * const *shaper_list)
{
if (unlikely (!buffer->len))
return true;
assert (buffer->content_type == HB_BUFFER_CONTENT_TYPE_UNICODE);
hb_shape_plan_t *shape_plan = hb_shape_plan_create_cached (font->face, &buffer->props, features, num_features, shaper_list);
hb_bool_t res = hb_shape_plan_execute (shape_plan, font, buffer, features, num_features);
hb_shape_plan_destroy (shape_plan);