diff options
| author | raysan5 <[email protected]> | 2020-09-16 11:33:56 +0200 |
|---|---|---|
| committer | raysan5 <[email protected]> | 2020-09-16 11:33:56 +0200 |
| commit | 43d82c1f21a2432d290e44bf223d2879f5af8837 (patch) | |
| tree | c929c97342b4e5e81885d148ef795a0d0c396cbb /src/text.c | |
| parent | c5c156d65e3a12e5b9abbf93c3a0cd51d29a5971 (diff) | |
| download | raylib-43d82c1f21a2432d290e44bf223d2879f5af8837.tar.gz raylib-43d82c1f21a2432d290e44bf223d2879f5af8837.zip | |
Add security checks when loading data from memory
Diffstat (limited to 'src/text.c')
| -rw-r--r-- | src/text.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -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); - // Loading font from memory data - font = LoadFontFromMemory(GetFileExtension(fileName), fileData, fileSize, fontSize, fontChars, charsCount); - - RL_FREE(fileData); + 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; } |
