]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
ggml-alloc: fix out-of-bounds read in ggml_dyn_tallocr_remove_block (ggml/1492)
authorDev-X25874 <redacted>
Thu, 21 May 2026 11:58:08 +0000 (17:28 +0530)
committerGeorgi Gerganov <redacted>
Mon, 25 May 2026 09:38:01 +0000 (12:38 +0300)
ggml/src/ggml-alloc.c

index a4b01ccf8a16a9de98335b698f92203404d454ac..3bda9abbe03dffbdb9ca1c25920c60ad87cf6bf1 100644 (file)
@@ -150,7 +150,7 @@ static void ggml_dyn_tallocr_insert_block(struct tallocr_chunk * chunk, size_t o
 
 static void ggml_dyn_tallocr_remove_block(struct tallocr_chunk * chunk, int idx) {
     // shift all elements after idx by 1 to the left, overwriting the element at idx
-    for (int i = idx; i < chunk->n_free_blocks; i++) {
+    for (int i = idx; i < chunk->n_free_blocks - 1; i++) {
         chunk->free_blocks[i] = chunk->free_blocks[i+1];
     }
     chunk->n_free_blocks--;