REVIEWED: LoadImageRaw()
#3926
This commit is contained in:
parent
8f24d86c1f
commit
cf47fbb20b
1 changed files with 11 additions and 8 deletions
|
@ -316,15 +316,18 @@ Image LoadImageRaw(const char *fileName, int width, int height, int format, int
|
||||||
unsigned char *dataPtr = fileData;
|
unsigned char *dataPtr = fileData;
|
||||||
unsigned int size = GetPixelDataSize(width, height, format);
|
unsigned int size = GetPixelDataSize(width, height, format);
|
||||||
|
|
||||||
// Offset file data to expected raw image by header size
|
if (size <= dataSize) // Security check
|
||||||
if ((headerSize > 0) && ((headerSize + size) <= dataSize)) 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
|
image.data = RL_MALLOC(size); // Allocate required memory in bytes
|
||||||
memcpy(image.data, dataPtr, size); // Copy required data to image
|
memcpy(image.data, dataPtr, size); // Copy required data to image
|
||||||
image.width = width;
|
image.width = width;
|
||||||
image.height = height;
|
image.height = height;
|
||||||
image.mipmaps = 1;
|
image.mipmaps = 1;
|
||||||
image.format = format;
|
image.format = format;
|
||||||
|
}
|
||||||
|
|
||||||
UnloadFileData(fileData);
|
UnloadFileData(fileData);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue