From: fairydreaming Date: Fri, 22 May 2026 12:50:44 +0000 (+0200) Subject: perplexity : fix integer overflow (#23496) X-Git-Tag: upstream/0.0.10438~1146 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=ef570f63087b6a5a2930210a13f87990e8113927;p=pkg%2Fggml%2Fsources%2Fllama.cpp perplexity : fix integer overflow (#23496) Co-authored-by: Stanisław Szymczyk --- 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)