REVIEWED: ImageDrawRectangleRec() #3027

This commit is contained in:
Ray 2023-04-25 14:16:48 +02:00
parent ac2e9cd00f
commit 6472928cf1

View file

@ -2996,6 +2996,12 @@ void ImageDrawRectangleRec(Image *dst, Rectangle rec, Color color)
// Security check to avoid program crash
if ((dst->data == NULL) || (dst->width == 0) || (dst->height == 0)) return;
// Security check to avoid drawing out of bounds in case of bad user data
if (rec.x < 0) { rec.width -= rec.x; rec.x = 0; }
if (rec.y < 0) { rec.height -= rec.y; rec.y = 0; }
if (rec.width < 0) rec.width = 0;
if (rec.heigh < 0) rec.height = 0;
int sy = (int)rec.y;
int ey = sy + (int)rec.height;