rtextures: Improve numerical stability of float multiplication

Dimensions of Rectangle should be casted to int before multiplication,
otherwise there is a risk for underallocation/overallocation of memory.
This commit is contained in:
Piotr Wiercinski 2022-07-27 17:16:20 +02:00
parent 5a2f25cc7c
commit 74be6f5c46

View File

@ -875,7 +875,7 @@ Image ImageFromImage(Image image, Rectangle rec)
result.width = (int)rec.width; result.width = (int)rec.width;
result.height = (int)rec.height; 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.format = image.format;
result.mipmaps = 1; result.mipmaps = 1;