From 679fac87dfbdef3192184b2d2374fda334205b41 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Thu, 30 Jul 2020 15:29:43 +0430 Subject: [PATCH] Skip hb_shape if buffer object is immutable --- src/hb-shape.cc | 2 ++ test/fuzzing/hb-shape-fuzzer.cc | 6 ++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hb-shape.cc b/src/hb-shape.cc index cf4e1525a..017fb91b6 100644 --- a/src/hb-shape.cc +++ b/src/hb-shape.cc @@ -132,6 +132,8 @@ hb_shape_full (hb_font_t *font, unsigned int num_features, const char * const *shaper_list) { + if (unlikely (hb_object_is_immutable (buffer))) return false; + hb_shape_plan_t *shape_plan = hb_shape_plan_create_cached2 (font->face, &buffer->props, features, num_features, font->coords, font->num_coords, diff --git a/test/fuzzing/hb-shape-fuzzer.cc b/test/fuzzing/hb-shape-fuzzer.cc index ced21248b..2bdf78719 100644 --- a/test/fuzzing/hb-shape-fuzzer.cc +++ b/test/fuzzing/hb-shape-fuzzer.cc @@ -35,8 +35,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) hb_buffer_t *buffer = hb_buffer_create (); hb_buffer_add_utf8 (buffer, text, -1, 0, -1); hb_buffer_guess_segment_properties (buffer); - if (hb_buffer_get_content_type (buffer) != HB_BUFFER_CONTENT_TYPE_INVALID) - hb_shape (font, buffer, nullptr, 0); + hb_shape (font, buffer, nullptr, 0); hb_buffer_destroy (buffer); } @@ -53,8 +52,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) hb_buffer_t *buffer = hb_buffer_create (); hb_buffer_add_utf32 (buffer, text32, sizeof (text32) / sizeof (text32[0]), 0, -1); hb_buffer_guess_segment_properties (buffer); - if (hb_buffer_get_content_type (buffer) != HB_BUFFER_CONTENT_TYPE_INVALID) - hb_shape (font, buffer, nullptr, 0); + hb_shape (font, buffer, nullptr, 0); hb_buffer_destroy (buffer); hb_font_destroy (font);