]> git.djapps.eu Git - pkg/ggml/sources/ggml/commitdiff
ggml : correct off-by-one bounds check in ggml_compute_forward_set_f32 (#229)
authorLoganDark <redacted>
Wed, 7 Jun 2023 16:16:19 +0000 (09:16 -0700)
committerGitHub <redacted>
Wed, 7 Jun 2023 16:16:19 +0000 (19:16 +0300)
without this fix you will be unable to set a zero-length tensor to the end of another tensor

this sounds stupid, but is used in my testing

src/ggml.c

index f4150161a87c5a689b9164c5db22cac21e437b55..c485733fcf7ef42e2f85b2839b5c485af5014b63 100644 (file)
@@ -10359,7 +10359,7 @@ static void ggml_compute_forward_set_f32(
     const int im2 = (ne12 == 0 ? 0 : ne12-1);
     const int im3 = (ne13 == 0 ? 0 : ne13-1);
 
-    GGML_ASSERT(offset + im0*nb0  + im1*nb1  + im2*nb2  + im3*nb3  < ggml_nbytes(dst));
+    GGML_ASSERT(offset + im0*nb0  + im1*nb1  + im2*nb2  + im3*nb3  <= ggml_nbytes(dst));
 
     GGML_ASSERT(nb10 == sizeof(float));