Skip to content

Commit

Permalink
grammar-parser: fix possible null-deref
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidKorczynski committed Aug 12, 2024
1 parent d3ae0ee commit 627b7f9
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions common/grammar-parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,9 @@ namespace grammar_parser {
}
// Validate the state to ensure that all rules are defined
for (const auto & rule : state.rules) {
if (rule.empty()) {
throw std::runtime_error("Undefined rule");
}
for (const auto & elem : rule) {
if (elem.type == LLAMA_GRETYPE_RULE_REF) {
// Ensure that the rule at that location exists
Expand Down

0 comments on commit 627b7f9

Please sign in to comment.