Skip to content

Commit

Permalink
grammar-parser : fix possible null-deref (ggerganov#9004)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidKorczynski authored and arthw committed Nov 18, 2024
1 parent 1b608cb commit c8f179c
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 c8f179c

Please sign in to comment.