From f5963ddcbeb7e7b1f15be521cf4e3ad8d913f7d1 Mon Sep 17 00:00:00 2001 From: Fredrik Hultin Date: Fri, 2 Aug 2024 10:36:46 +0200 Subject: [PATCH] [rtextures] Promote calculation to long long in GetPixelDataSize() to allow for larger image sizes. --- src/rtextures.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/rtextures.c b/src/rtextures.c index 60ce58f4b..d445396c7 100644 --- a/src/rtextures.c +++ b/src/rtextures.c @@ -5403,7 +5403,9 @@ int GetPixelDataSize(int width, int height, int format) default: break; } - dataSize = width*height*bpp/8; // Total data size in bytes + // Total data size in bytes + // NOTE: promote to long long during calculation to avoid overflows before dividing by 8 + dataSize = width*height*(long long)bpp/8; // Most compressed formats works on 4x4 blocks, // if texture is smaller, minimum dataSize is 8 or 16