mirror of
https://github.com/raysan5/raylib.git
synced 2025-10-03 08:28:30 +00:00
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.
This commit is contained in:
@@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user