Skip to content

Commit

Permalink
grammar-parser : fix possible null-deref (#9004)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidKorczynski authored Aug 12, 2024
1 parent df5478f commit 1262e7e
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 1262e7e

Please sign in to comment.