summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorPiotr WierciƄski <[email protected]>2022-07-26 20:53:36 +0200
committerGitHub <[email protected]>2022-07-26 20:53:36 +0200
commit5a2f25cc7c7ab7d4600bdc565b9f1da2d9211b4c (patch)
treef50bc62a351351a403615f9beb8faa343dd45428 /src
parent6f3a633f2e3991c443b9502a74cf90b43a611c99 (diff)
downloadraylib-5a2f25cc7c7ab7d4600bdc565b9f1da2d9211b4c.tar.gz
raylib-5a2f25cc7c7ab7d4600bdc565b9f1da2d9211b4c.zip
rtextures: Fix ImageFromImage crash (#2594)
Height of the rectangle can be float, which may lead to doing extra iteration of loop and writing out of bounds.
Diffstat (limited to 'src')
-rw-r--r--src/rtextures.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/rtextures.c b/src/rtextures.c
index 7cc350c5..6eb77b7d 100644
--- a/src/rtextures.c
+++ b/src/rtextures.c
@@ -879,7 +879,7 @@ Image ImageFromImage(Image image, Rectangle rec)
result.format = image.format;
result.mipmaps = 1;
- for (int y = 0; y < rec.height; y++)
+ for (int y = 0; y < (int)rec.height; y++)
{
memcpy(((unsigned char *)result.data) + y*(int)rec.width*bytesPerPixel, ((unsigned char *)image.data) + ((y + (int)rec.y)*image.width + (int)rec.x)*bytesPerPixel, (int)rec.width*bytesPerPixel);
}