[OTLayout] Don't recurse in collect_glyphs() for GPOS
diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index 7bf3e71..bdeae84 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -156,6 +156,10 @@
if (unlikely (nesting_level_left == 0 || !recurse_func))
return default_return_value ();
+ /* Note that GPOS sets recurse_func to NULL already, so it doesn't get
+ * past the previous check. For GSUB, we only want to collect the output
+ * glyphs in the recursion. If those are not requested, we can go home now. */
+
nesting_level_left--;
/* Only collect output glyphs in the recursion. */
hb_collect_glyphs_context_t new_c (this->face, NULL, NULL, NULL, &output, nesting_level_left);