diff options
| author | Jeffery Myers <[email protected]> | 2023-08-26 05:43:14 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-08-26 14:43:14 +0200 |
| commit | 21f5482e0d6e935e69118f6028da472065ea8317 (patch) | |
| tree | 6c0fcd7536dc30a83252fbeef420406aec89a38c /src | |
| parent | 4fa66f26359ba21068db15b1268cf7fb03422afa (diff) | |
| download | raylib-21f5482e0d6e935e69118f6028da472065ea8317.tar.gz raylib-21f5482e0d6e935e69118f6028da472065ea8317.zip | |
[Image] Validate that ImageDrawRectangleRec is drawing entirely inside the image (#3264)
* Add a function to clone a sound and share data with another sound.
* rename items based on feedback
* PR Feedback, use custom unload for sound alias, not variant of normal sound unloading
* sound_multi example
* Validate that image rect drawing is inside the image so we don't overflow a buffer
* remove files that should not have been added.
* remove changes that should not have been
* revert
* adsfasdfsdfsdf
Diffstat (limited to 'src')
| -rw-r--r-- | src/rtextures.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/rtextures.c b/src/rtextures.c index 4b697f77..f32a45d1 100644 --- a/src/rtextures.c +++ b/src/rtextures.c @@ -3284,6 +3284,20 @@ void ImageDrawRectangleRec(Image *dst, Rectangle rec, Color color) if (rec.width < 0) rec.width = 0; if (rec.height < 0) rec.height = 0; + // clamp the size the the image bounds + if (rec.x + rec.width >= dst->width) + rec.width = dst->width - rec.x; + + if (rec.y + rec.height >= dst->height) + rec.height = dst->height - rec.y; + + // 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; + int sy = (int)rec.y; int sx = (int)rec.x; |
