Commit dbe4c3ed4 for llama.cpp
commit dbe4c3ed42343f0a7ba0fd7e808ffeaca404d29f
Author: Anas <alhachemi.anas@proton.me>
Date: Sun Oct 4 17:59:21 2026 +0200
chat-peg-parser : clear current_tool when pending_tool_call is reset (#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.
diff --git a/common/chat-peg-parser.cpp b/common/chat-peg-parser.cpp
index f82797495..ee9a05fe0 100644
--- a/common/chat-peg-parser.cpp
+++ b/common/chat-peg-parser.cpp
@@ -451,6 +451,7 @@ void common_chat_peg_mapper::map(const common_peg_ast_node & node) {
result.tool_calls.push_back(pending_tool_call.value());
}
pending_tool_call.reset();
+ current_tool = nullptr;
}
}
}