Warning on invalid image data (#4179)
Some checks are pending
Android / build (arm64) (push) Waiting to run
Android / build (x86_64) (push) Waiting to run
CMakeBuilds / Windows Build (push) Waiting to run
CMakeBuilds / Linux Build (push) Waiting to run
Linux / build (i386, i386, /user/bin, 32) (push) Waiting to run
Linux / build (x86_64, amd64, /user/bin, 64) (push) Waiting to run
Linux Examples / build (push) Waiting to run
macOS / build (push) Waiting to run
WebAssembly / build (push) Waiting to run
Windows / build (i686, pe-i386, 32, mingw-w64) (push) Waiting to run
Windows / build (x64, x64, 64, msvc16) (push) Waiting to run
Windows / build (x86, Win32, 32, msvc16) (push) Waiting to run
Windows / build (x86_64, pe-x86-64, 64, mingw-w64) (push) Waiting to run
Windows Examples / build (push) Waiting to run

* Adds log warnings on invalid file data

* Separate error on missing file extension

* Changed LOG_ERROR to LOG_WARNING

---------

Co-authored-by: Jutastre <pukarlindgren@gmail.com>
This commit is contained in:
Jutastre 2024-07-24 21:21:45 +02:00 committed by GitHub
parent bbcb0109e1
commit f5d2f8d545
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -503,7 +503,16 @@ Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, i
Image image = { 0 };
// Security check for input data
if ((fileType == NULL) || (fileData == NULL) || (dataSize == 0)) return image;
if ((fileData == NULL) || (dataSize == 0))
{
TRACELOG(LOG_WARNING, "IMAGE: Invalid file data");
return image;
}
if (fileType == NULL)
{
TRACELOG(LOG_WARNING, "IMAGE: Missing file extension");
return image;
}
if ((false)
#if defined(SUPPORT_FILEFORMAT_PNG)