Add security checks when loading data from memory
This commit is contained in:
parent
c5c156d65e
commit
43d82c1f21
@ -694,10 +694,13 @@ Wave LoadWave(const char *fileName)
|
||||
unsigned int fileSize = 0;
|
||||
unsigned char *fileData = LoadFileData(fileName, &fileSize);
|
||||
|
||||
if (fileData != NULL)
|
||||
{
|
||||
// Loading wave from memory data
|
||||
wave = LoadWaveFromMemory(GetFileExtension(fileName), fileData, fileSize);
|
||||
|
||||
RL_FREE(fileData);
|
||||
}
|
||||
|
||||
return wave;
|
||||
}
|
||||
|
@ -340,10 +340,14 @@ Font LoadFontEx(const char *fileName, int fontSize, int *fontChars, int charsCou
|
||||
unsigned int fileSize = 0;
|
||||
unsigned char *fileData = LoadFileData(fileName, &fileSize);
|
||||
|
||||
if (fileData != NULL)
|
||||
{
|
||||
// Loading font from memory data
|
||||
font = LoadFontFromMemory(GetFileExtension(fileName), fileData, fileSize, fontSize, fontChars, charsCount);
|
||||
|
||||
RL_FREE(fileData);
|
||||
}
|
||||
else font = GetFontDefault();
|
||||
|
||||
return font;
|
||||
}
|
||||
|
@ -211,6 +211,8 @@ Image LoadImage(const char *fileName)
|
||||
unsigned int fileSize = 0;
|
||||
unsigned char *fileData = LoadFileData(fileName, &fileSize);
|
||||
|
||||
if (fileData != NULL)
|
||||
{
|
||||
// Loading image from memory data
|
||||
image = LoadImageFromMemory(GetFileExtension(fileName), fileData, fileSize);
|
||||
|
||||
@ -218,6 +220,7 @@ Image LoadImage(const char *fileName)
|
||||
else TRACELOG(LOG_WARNING, "IMAGE: [%s] Failed to load data", fileName);
|
||||
|
||||
RL_FREE(fileData);
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user