From 9c2ba3bfb7166b71a852d4a4912363d0977c8676 Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 4 Aug 2024 23:22:27 +0200 Subject: [PATCH] REVIEWED: possible overflow... again #4206 --- src/rlgl.h | 4 ++-- src/rtextures.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/rlgl.h b/src/rlgl.h index 7eb1bb1d3..3ff6d7e2a 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -4993,8 +4993,8 @@ static int rlGetPixelDataSize(int width, int height, int format) default: break; } - char bytesPerPixel = bpp/8; - dataSize = width*height*bytesPerPixel; // Total data size in bytes + float bytesPerPixel = (float)bpp/8.0f; + dataSize = (int)(bytesPerPixel*width*height); // Total data size in bytes // Most compressed formats works on 4x4 blocks, // if texture is smaller, minimum dataSize is 8 or 16 diff --git a/src/rtextures.c b/src/rtextures.c index 94ad81e20..9359f9219 100644 --- a/src/rtextures.c +++ b/src/rtextures.c @@ -5403,8 +5403,8 @@ int GetPixelDataSize(int width, int height, int format) default: break; } - char bytesPerPixel = bpp/8; - dataSize = width*height*bytesPerPixel; // Total data size in bytes + float bytesPerPixel = (float)bpp/8.0f; + dataSize = (int)(bytesPerPixel*width*height); // Total data size in bytes // Most compressed formats works on 4x4 blocks, // if texture is smaller, minimum dataSize is 8 or 16