From 216cf5946bdea85b954c73669c085437f9e99a72 Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Tue, 5 Jul 2022 17:49:12 +0000 Subject: [PATCH] [subset] Allocate space for null entry in script/feature list. --- src/hb-subset-plan.cc | 8 +++----- src/hb-subset.h | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/hb-subset-plan.cc b/src/hb-subset-plan.cc index 851504fa9..68a1741ff 100644 --- a/src/hb-subset-plan.cc +++ b/src/hb-subset-plan.cc @@ -99,7 +99,7 @@ static bool _filter_tag_list(hb_vector_t* tags, /* IN/OUT */ const hb_set_t* filter) { hb_vector_t out; - out.alloc (tags->get_size()); + out.alloc (tags->get_size() + 1); // +1 is to allocate room for the null terminator. bool removed = false; hb_set_t visited; @@ -129,18 +129,16 @@ static void _collect_layout_indices (hb_subset_plan_t *plan, layout_collect_func_t layout_collect_func, hb_set_t *indices /* OUT */) { - unsigned num_features = table.get_feature_count () + 1; + unsigned num_features = table.get_feature_count (); hb_vector_t features; if (!plan->check_success (features.resize (num_features))) return; table.get_feature_tags (0, &num_features, features.arrayZ); - features.resize (num_features); bool retain_all_features = !_filter_tag_list (&features, plan->layout_features); - unsigned num_scripts = table.get_script_count () + 1; + unsigned num_scripts = table.get_script_count (); hb_vector_t scripts; if (!plan->check_success (scripts.resize (num_scripts))) return; table.get_script_tags (0, &num_scripts, scripts.arrayZ); - scripts.resize (num_scripts); bool retain_all_scripts = !_filter_tag_list (&scripts, plan->layout_scripts); if (!plan->check_success (!features.in_error ()) || !features diff --git a/src/hb-subset.h b/src/hb-subset.h index 636e399a6..d0064cbfe 100644 --- a/src/hb-subset.h +++ b/src/hb-subset.h @@ -101,7 +101,7 @@ typedef enum { /*< flags >*/ * @HB_SUBSET_SETS_LAYOUT_FEATURE_TAG: the set of layout feature tags that will be retained * in the subset. * @HB_SUBSET_SETS_LAYOUT_SCRIPT_TAG: the set of layout script tags that will be retained - * in the subset. Defaults to all tags. + * in the subset. Defaults to all tags. Since: REPLACEME * * List of sets that can be configured on the subset input. *