]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
perplexity : fix integer overflow (#23496)
authorfairydreaming <redacted>
Fri, 22 May 2026 12:50:44 +0000 (14:50 +0200)
committerGitHub <redacted>
Fri, 22 May 2026 12:50:44 +0000 (15:50 +0300)
Co-authored-by: Stanisław Szymczyk <redacted>
tools/perplexity/perplexity.cpp

index f66576eb40476dd4a115dcf8572c1711fa0a1b43..ea9de83e1a985933982d0aa3901db40061d35bcb 100644 (file)
@@ -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)