Skip to content

Commit

Permalink
ggml : always check bounds on get_rows operations (#9354)
Browse files Browse the repository at this point in the history
  • Loading branch information
slaren authored Sep 7, 2024
1 parent df270ef commit e32d081
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ggml/src/ggml.c
Original file line number Diff line number Diff line change
Expand Up @@ -13721,7 +13721,7 @@ static void ggml_compute_forward_get_rows_q(
const int64_t i10 = (i - i12*ne11*ne10 - i11*ne10);
const int64_t i01 = *(int32_t *) ((char *) src1->data + i10*nb10 + i11*nb11 + i12*nb12);

assert(i01 >= 0 && i01 < ne01);
GGML_ASSERT(i01 >= 0 && i01 < ne01);

dequantize_row_q(
(const void *) ((char *) src0->data + i01*nb01 + i11*nb02 + i12*nb03),
Expand Down Expand Up @@ -13762,7 +13762,7 @@ static void ggml_compute_forward_get_rows_f16(
const int64_t i10 = (i - i12*ne11*ne10 - i11*ne10);
const int64_t i01 = *(int32_t *) ((char *) src1->data + i10*nb10 + i11*nb11 + i12*nb12);

assert(i01 >= 0 && i01 < ne01);
GGML_ASSERT(i01 >= 0 && i01 < ne01);

ggml_fp16_to_fp32_row(
(const void *) ((char *) src0->data + i01*nb01 + i11*nb02 + i12*nb03),
Expand Down Expand Up @@ -13803,7 +13803,7 @@ static void ggml_compute_forward_get_rows_bf16(
const int64_t i10 = (i - i12*ne11*ne10 - i11*ne10);
const int64_t i01 = *(int32_t *) ((char *) src1->data + i10*nb10 + i11*nb11 + i12*nb12);

assert(i01 >= 0 && i01 < ne01);
GGML_ASSERT(i01 >= 0 && i01 < ne01);

ggml_bf16_to_fp32_row(
(const void *) ((char *) src0->data + i01*nb01 + i11*nb02 + i12*nb03),
Expand Down Expand Up @@ -13844,7 +13844,7 @@ static void ggml_compute_forward_get_rows_f32(
const int64_t i10 = (i - i12*ne11*ne10 - i11*ne10);
const int64_t i01 = *(int32_t *) ((char *) src1->data + i10*nb10 + i11*nb11 + i12*nb12);

assert(i01 >= 0 && i01 < ne01);
GGML_ASSERT(i01 >= 0 && i01 < ne01);

ggml_vec_cpy_f32(nc,
(float *) ((char *) dst->data + i10*nb1 + i11*nb2 + i12*nb3),
Expand Down

0 comments on commit e32d081

Please sign in to comment.