diff options
| author | Ray <[email protected]> | 2024-04-20 23:44:07 +0200 |
|---|---|---|
| committer | Ray <[email protected]> | 2024-04-20 23:44:07 +0200 |
| commit | 8f24d86c1f1ca282672ba467c17abf74415c4500 (patch) | |
| tree | 2d008593e29eed7c08d4d32da0006fcb4a7afba7 /src | |
| parent | f795941521d038840461e96779aaa097e8a2407a (diff) | |
| download | raylib-8f24d86c1f1ca282672ba467c17abf74415c4500.tar.gz raylib-8f24d86c1f1ca282672ba467c17abf74415c4500.zip | |
REVIEWED: `LoadImageRaw()` #3926
Diffstat (limited to 'src')
| -rw-r--r-- | src/rtextures.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/rtextures.c b/src/rtextures.c index 35757ba1..0899accd 100644 --- a/src/rtextures.c +++ b/src/rtextures.c @@ -316,7 +316,8 @@ Image LoadImageRaw(const char *fileName, int width, int height, int format, int unsigned char *dataPtr = fileData; unsigned int size = GetPixelDataSize(width, height, format); - if (headerSize > 0) dataPtr += headerSize; + // Offset file data to expected raw image by header size + if ((headerSize > 0) && ((headerSize + size) <= dataSize)) dataPtr += headerSize; image.data = RL_MALLOC(size); // Allocate required memory in bytes memcpy(image.data, dataPtr, size); // Copy required data to image |
