llama-grammar: Fix integer overflow (#32551)

* llama-grammar: Fix integer overflow

* Check incorrect values at parsing and bail out nicely

* fix style
This commit is contained in:
Daniel Kuts authored and GitHub committed 2026-11-21 07:00:30 +01:00
1 parent 6792507b7f
commit 46eb1742db
1 file changed
+3
+3
View File
@@ -668,6 +668,9 @@ const char * llama_grammar_parser::parse_sequence(
if (max_times != UINT64_MAX && max_times > MAX_REPETITION_THRESHOLD) {
max_times = UINT64_MAX;
}
if (max_times < min_times) {
throw std::runtime_error(std::string("incorrect number of repetitions"));
}
handle_repetitions(min_times, max_times);
} else {
break;