From ef570f63087b6a5a2930210a13f87990e8113927 Mon Sep 17 00:00:00 2001 From: fairydreaming <166155368+fairydreaming@users.noreply.github.com> Date: Fri, 22 May 2026 14:50:44 +0200 Subject: [PATCH] perplexity : fix integer overflow (#23496) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Stanisław Szymczyk --- tools/perplexity/perplexity.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perplexity/perplexity.cpp b/tools/perplexity/perplexity.cpp index f66576eb4..ea9de83e1 100644 --- a/tools/perplexity/perplexity.cpp +++ b/tools/perplexity/perplexity.cpp @@ -524,7 +524,7 @@ static results_perplexity perplexity(llama_context * ctx, const common_params & logits_stream.write((const char *)&n_chunk, sizeof(n_chunk)); logits_stream.write((const char *)tokens.data(), n_chunk*n_ctx*sizeof(tokens[0])); const int nv = 2*((n_vocab + 1)/2) + 4; - log_probs.resize(n_ctx * nv); + log_probs.resize(size_t(n_ctx) * nv); } // We get the logits for all the tokens in the context window (params.n_ctx)