From d04cfaf2f5844455c8e773edf0d7f02919d3249c Mon Sep 17 00:00:00 2001 From: Francis Couture-Harpin Date: Mon, 18 Mar 2024 21:26:08 -0400 Subject: [PATCH] llama : fix llama_output_reserve nullptr deref when new_size is 0 --- llama.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llama.cpp b/llama.cpp index 075b1937a..faf65e339 100644 --- a/llama.cpp +++ b/llama.cpp @@ -9195,7 +9195,7 @@ static void llama_output_reserve(llama_context & lctx, int32_t n_outputs) { // alloc only when more than the current capacity is required // TODO: also consider shrinking the buffer - if (prev_size < new_size) { + if (!lctx.buf_output || prev_size < new_size) { if (lctx.buf_output) { #ifndef NDEBUG // This doesn't happen often, but may be annoying in some cases (like the HellaSwag benchmark)