Skip to content

Commit d04cfaf

Browse files
committed
llama : fix llama_output_reserve nullptr deref when new_size is 0
1 parent 8b826c5 commit d04cfaf

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

llama.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -9195,7 +9195,7 @@ static void llama_output_reserve(llama_context & lctx, int32_t n_outputs) {
91959195

91969196
// alloc only when more than the current capacity is required
91979197
// TODO: also consider shrinking the buffer
9198-
if (prev_size < new_size) {
9198+
if (!lctx.buf_output || prev_size < new_size) {
91999199
if (lctx.buf_output) {
92009200
#ifndef NDEBUG
92019201
// This doesn't happen often, but may be annoying in some cases (like the HellaSwag benchmark)

0 commit comments

Comments
 (0)