Corrected possible memory leak
This commit is contained in:
parent
44181baf04
commit
559b9b8cc3
@ -311,6 +311,7 @@ Font LoadFontEx(const char *fileName, int fontSize, int charsCount, int *fontCha
|
|||||||
{
|
{
|
||||||
Font spriteFont = { 0 };
|
Font spriteFont = { 0 };
|
||||||
int totalChars = 95; // Default charset [32..126]
|
int totalChars = 95; // Default charset [32..126]
|
||||||
|
bool fontCharsLoaded = false;
|
||||||
|
|
||||||
#if defined(SUPPORT_FILEFORMAT_TTF)
|
#if defined(SUPPORT_FILEFORMAT_TTF)
|
||||||
if (IsFileExtension(fileName, ".ttf"))
|
if (IsFileExtension(fileName, ".ttf"))
|
||||||
@ -321,9 +322,12 @@ Font LoadFontEx(const char *fileName, int fontSize, int charsCount, int *fontCha
|
|||||||
{
|
{
|
||||||
fontChars = (int *)malloc(totalChars*sizeof(int));
|
fontChars = (int *)malloc(totalChars*sizeof(int));
|
||||||
for (int i = 0; i < totalChars; i++) fontChars[i] = i + 32; // Default first character: SPACE[32]
|
for (int i = 0; i < totalChars; i++) fontChars[i] = i + 32; // Default first character: SPACE[32]
|
||||||
|
fontCharsLoaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
spriteFont = LoadTTF(fileName, fontSize, totalChars, fontChars);
|
spriteFont = LoadTTF(fileName, fontSize, totalChars, fontChars);
|
||||||
|
|
||||||
|
if (fontCharsLoaded) free(fontChars);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user