Skip to content

Commit

Permalink
llama : fix llama_output_reserve nullptr deref when new_size is 0
Browse files Browse the repository at this point in the history
  • Loading branch information
compilade committed Mar 19, 2024
1 parent 8b826c5 commit d04cfaf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion llama.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d04cfaf

Please sign in to comment.