Skip to content

LLM inference in C/C++

C++ ggml

server: reject partial media truncation (#24076)

Yufeng He8e1642198dcd
diff --git a/tools/server/server-common.cpp b/tools/server/server-common.cpp
index be87c45f7f..076a857416 100644
--- a/tools/server/server-common.cpp
+++ b/tools/server/server-common.cpp
@@ -667,7 +667,7 @@ void server_tokens::keep_first(size_t n) {
// note that the case where we keep a full image at the end is allowed:
// tokens[n - 1] == LLAMA_TOKEN_NULL && tokens[n] != LLAMA_TOKEN_NULL
if (tokens[n - 1] == LLAMA_TOKEN_NULL && tokens[n] == LLAMA_TOKEN_NULL) {
- find_chunk(n - 1); // will throw an error if the token is not begin-of-chunk
+ find_chunk(n); // will throw an error if the cut is not at a chunk boundary
}
}
// remove all image chunks that are not used anymore