ggml-alloc: fix out-of-bounds read in ggml_dyn_tallocr_remove_block (ggml/1492)
This commit is contained in:
committed by
Georgi Gerganov
parent
ae251b5ff2
commit
fa97041524
@@ -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) {
|
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
|
// 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->free_blocks[i] = chunk->free_blocks[i+1];
|
||||||
}
|
}
|
||||||
chunk->n_free_blocks--;
|
chunk->n_free_blocks--;
|
||||||
|
|||||||
Reference in New Issue
Block a user