From 4cf1474dfa5ca73c985cb246d95d8214dac4e978 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 2 Oct 2026 02:36:32 -0600 Subject: [PATCH] [repacker] Reset graph state before assigning spaces Overflow resolution can retry GSUB/GPOS specialization on an already modified graph. Clear derived space and priority state before assigning spaces again so retries do not accumulate stale space identifiers. Use the full signed range available to the packed distance key instead of saturating valid distances as the number of spaces grows. Assisted-by: OpenAI Codex --- src/graph/graph.hh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/graph/graph.hh b/src/graph/graph.hh index 9ec9f22c7..d944bf357 100644 --- a/src/graph/graph.hh +++ b/src/graph/graph.hh @@ -476,7 +476,8 @@ struct graph_t // it's parent where possible. int64_t modified_distance = - hb_clamp (distance + distance_modifier (), (int64_t) 0, 0x7FFFFFFFFFF); + hb_clamp (distance + distance_modifier (), (int64_t) 0, + hb_int_max (int64_t) >> 18); if (has_max_priority ()) { modified_distance = 0; } @@ -938,6 +939,17 @@ public: { TRY (update_parents ()); + for (auto& vertex : vertices_.writer ()) + { + vertex.space = 0; + vertex.priority = 0; + } + num_roots_for_space_.resize (1); + TRY (graph_result_t::from (num_roots_for_space_, ALLOCATION_FAILURE)); + num_roots_for_space_[0] = 1; + distance_invalid = true; + positions_invalid = true; + hb_set_t visited; hb_set_t roots; TRY (find_space_roots (visited, roots));