소스 검색

Fix bounds check for `ImageDrawRectangleRec` (#3732)

Blockguy24 1 년 전
부모
커밋
d2b1256e5c
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 2
      src/rtextures.c

+ 2 - 2
src/rtextures.c

@@ -3586,8 +3586,8 @@ void ImageDrawRectangleRec(Image *dst, Rectangle rec, Color color)
     if ((rec.y + rec.height) >= dst->height) rec.height = dst->height - rec.y;
     if ((rec.y + rec.height) >= dst->height) rec.height = dst->height - rec.y;
 
 
     // Check if the rect is even inside the image
     // Check if the rect is even inside the image
-    if ((rec.x > dst->width) || (rec.y > dst->height)) return;
-    if (((rec.x + rec.width) < 0) || (rec.y + rec.height < 0)) return;
+    if ((rec.x >= dst->width) || (rec.y >= dst->height)) return;
+    if (((rec.x + rec.width) <= 0) || (rec.y + rec.height <= 0)) return;
 
 
     int sy = (int)rec.y;
     int sy = (int)rec.y;
     int sx = (int)rec.x;
     int sx = (int)rec.x;