Skip to content

Commit dbe4c3e

Browse files
authored
chat-peg-parser : clear current_tool when pending_tool_call is reset (ggml-org#29942)
A TOOL_ID node that arrives after TOOL_CLOSE wrote through `current_tool`, which still pointed into the just-destroyed `pending_tool_call` optional (use-after-free, then a second free of the id buffer). Clear the pointer on reset.
1 parent 46847e6 commit dbe4c3e

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

‎common/chat-peg-parser.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ void common_chat_peg_mapper::map(const common_peg_ast_node & node) {
451451
result.tool_calls.push_back(pending_tool_call.value());
452452
}
453453
pending_tool_call.reset();
454+
current_tool = nullptr;
454455
}
455456
}
456457
}

0 commit comments

Comments
 (0)