Skip to content

Commit

Permalink
llamacpp: free grammar if successful (google#12280)
Browse files Browse the repository at this point in the history
Signed-off-by: David Korczynski <[email protected]>
  • Loading branch information
DavidKorczynski authored Jul 26, 2024
1 parent 0610578 commit 0af0a84
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion projects/llamacpp/fuzzers/fuzz_grammar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
parsed_grammar.symbol_ids.end()) {
std::vector<const llama_grammar_element *> grammar_rules(
parsed_grammar.c_rules());
llama_grammar_init(grammar_rules.data(), grammar_rules.size(),
auto grammar = llama_grammar_init(grammar_rules.data(), grammar_rules.size(),
parsed_grammar.symbol_ids.at("root"));
if (grammar != nullptr) {
llama_grammar_free(grammar);
}
}
return 0;
}

0 comments on commit 0af0a84

Please sign in to comment.