Skip to content

Commit

Permalink
tool-call: fix memory leak in test
Browse files Browse the repository at this point in the history
  • Loading branch information
ochafik committed Sep 28, 2024
1 parent 22493c8 commit c87c121
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tests/test-tool-call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ static std::string read_file(const std::string &path) {
return out;
}

static llama_grammar * build_grammar(const std::string & grammar_str) {
return llama_grammar_init_impl(nullptr, grammar_str.c_str(), "root");
static std::unique_ptr<llama_grammar> build_grammar(const std::string & grammar_str) {
return std::unique_ptr<llama_grammar>(llama_grammar_init_impl(nullptr, grammar_str.c_str(), "root"));
}

// TODO: extract to common helper (copied from test-grammar-integration.cpp)
Expand Down Expand Up @@ -292,7 +292,7 @@ static void test_template(const std::string & template_file, const char * bos_to
{"content", ""},
{"tool_calls", tool_calls}
}, tools);
if (!match_string(content_less_delta, grammar)) {
if (!match_string(content_less_delta, grammar.get())) {
throw std::runtime_error("Failed to match content-less delta against grammar:\n\nContent-less delta: " + content_less_delta + "\n\nGrammar: " + handler.grammar);
}
}
Expand Down

0 comments on commit c87c121

Please sign in to comment.