From 2694d328fefcfd69f44942e6e606286a8f0f4e51 Mon Sep 17 00:00:00 2001 From: Piotr Wiercinski Date: Tue, 26 Jul 2022 20:45:01 +0200 Subject: [PATCH] rtextures: Fix ImageFromImage crash Height of the rectangle can be float, which may lead to doing extra iteration of loop and writing out of bounds. --- src/rtextures.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rtextures.c b/src/rtextures.c index 7cc350c5d67a..6eb77b7de846 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); }