diff --git a/common/json-schema-to-grammar.cpp b/common/json-schema-to-grammar.cpp index 5b3059c2f774f..1cda6599f6db5 100644 --- a/common/json-schema-to-grammar.cpp +++ b/common/json-schema-to-grammar.cpp @@ -483,7 +483,8 @@ class SchemaConverter { seq.emplace_back("|", false); i++; } else if (c == '*' || c == '+' || c == '?') { - seq.back() = std::make_pair(to_rule(seq.back()) + c, false); + if (!seq.empty()) + seq.back() = std::make_pair(to_rule(seq.back()) + c, false); i++; } else if (c == '{') { std::string curly_brackets = std::string(1, c);