From f84809b7adfeaafaa77101aa249f41c4180486ce Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Tue, 5 Mar 2024 17:23:18 +0200 Subject: [PATCH] llama : llama_chat_apply_template support null buf --- llama.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/llama.cpp b/llama.cpp index 76afcbc13..f95328601 100644 --- a/llama.cpp +++ b/llama.cpp @@ -13544,7 +13544,9 @@ LLAMA_API int32_t llama_chat_apply_template( if (res < 0) { return res; } - strncpy(buf, formatted_chat.c_str(), length); + if (buf && length > 0) { + strncpy(buf, formatted_chat.c_str(), length); + } return res; }