From 024a803665077b05ae7846b4e4a8ce8c70a306e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wierci=C5=84ski?= Date: Wed, 27 Jul 2022 17:31:52 +0200 Subject: [PATCH] rtextures: Improve numerical stability of float multiplication (#2596) Dimensions of Rectangle should be casted to int before multiplication, otherwise there is a risk for underallocation/overallocation of memory. --- src/rtextures.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rtextures.c b/src/rtextures.c index 6eb77b7de..39a7a5c03 100644 --- a/src/rtextures.c +++ b/src/rtextures.c @@ -875,7 +875,7 @@ Image ImageFromImage(Image image, Rectangle rec) result.width = (int)rec.width; result.height = (int)rec.height; - result.data = RL_CALLOC((int)(rec.width*rec.height)*bytesPerPixel, 1); + result.data = RL_CALLOC((int)rec.width*(int)rec.height*bytesPerPixel, 1); result.format = image.format; result.mipmaps = 1;