diff --git a/src/runtime/c/pgf/linearizer.cxx b/src/runtime/c/pgf/linearizer.cxx index 29c0fe937..2721edd17 100644 --- a/src/runtime/c/pgf/linearizer.cxx +++ b/src/runtime/c/pgf/linearizer.cxx @@ -184,13 +184,15 @@ void PgfLinearizer::flush_pre_stack(PgfLinearizationOutputIface *out, PgfText *t PreStack *pre = pre_stack; pre_stack = pre->next; - for (size_t i = 0; i < pre->sym_kp->alts.len; i++) { - PgfAlternative *alt = &pre->sym_kp->alts.data[i]; - for (size_t j = 0; j < alt->prefixes->len; j++) { - ref prefix = *vector_elem(alt->prefixes,j); - if (textstarts(token, &(*prefix))) { - linearize(out, pre->node, alt->form); - goto done; + if (token != NULL) { + for (size_t i = 0; i < pre->sym_kp->alts.len; i++) { + PgfAlternative *alt = &pre->sym_kp->alts.data[i]; + for (size_t j = 0; j < alt->prefixes->len; j++) { + ref prefix = *vector_elem(alt->prefixes,j); + if (textstarts(token, &(*prefix))) { + linearize(out, pre->node, alt->form); + goto done; + } } } } diff --git a/src/runtime/c/pgf/linearizer.h b/src/runtime/c/pgf/linearizer.h index 6c311804a..b27b31c05 100644 --- a/src/runtime/c/pgf/linearizer.h +++ b/src/runtime/c/pgf/linearizer.h @@ -82,6 +82,7 @@ public: void reverse_and_label(); void linearize(PgfLinearizationOutputIface *out) { linearize(out, root, 0); + flush_pre_stack(out, NULL); } ~PgfLinearizer();