Skip to content

Commit 5596464

Browse files
authored
fix: prevent nullptr dereference (ggml-org#20552)
1 parent cf45437 commit 5596464

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

common/chat-diff-analyzer.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ analyze_content::analyze_content(const common_chat_template & tmpl, const analyz
479479

480480
if (!comparison_with_tools || !comparison_with_reasoning) {
481481
LOG_DBG(ANSI_ORANGE "%s: Template application failed\n" ANSI_RESET, __func__);
482+
return;
482483
}
483484

484485
const auto & diff_tools = comparison_with_tools->diff;
@@ -911,8 +912,10 @@ void analyze_tools::extract_function_markers() {
911912
// we'll have to rely on an extra diff with no-calls version
912913
auto notool_comp = compare_variants(
913914
*tmpl, params, [&](template_params & p) { p.messages = json::array({ user_msg, assistant_nocall }); });
914-
auto nt_diff = notool_comp->diff;
915-
closer_suffix = nt_diff.left.substr(nt_diff.left.find("YYYY") + 4);
915+
if (notool_comp) {
916+
auto nt_diff = notool_comp->diff;
917+
closer_suffix = nt_diff.left.substr(nt_diff.left.find("YYYY") + 4);
918+
}
916919
} else {
917920
closer_suffix = diff.suffix.substr(0, diff.suffix.find(suffix_marker));
918921
}

0 commit comments

Comments
 (0)