fix: ImageFromImage rectangle validation use >= and <= (#5979)

This commit is contained in:
Commmand_Prompt
2026-07-13 21:13:12 +08:00
committed by GitHub
parent b631fb3d05
commit 5de8c3521f

View File

@@ -1231,9 +1231,9 @@ Image ImageFromImage(Image image, Rectangle rec)
Image result = { 0 };
// Basic rectangle validation: size smaller than image size
if ((rec.x > 0) && (rec.y > 0) && (rec.width > 0) && (rec.height > 0) &&
(((int)rec.x + (int)rec.width) < image.width) &&
(((int)rec.y + (int)rec.height) < image.height))
if ((rec.x >= 0) && (rec.y >= 0) && (rec.width > 0) && (rec.height > 0) &&
(((int)rec.x + (int)rec.width) <= image.width) &&
(((int)rec.y + (int)rec.height) <= image.height))
{
int bytesPerPixel = GetPixelDataSize(1, 1, image.format);