summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorraysan5 <[email protected]>2018-05-21 18:57:54 +0200
committerraysan5 <[email protected]>2018-05-21 18:57:54 +0200
commit559b9b8cc36883670e5591fdc03cee2f0452fdf1 (patch)
tree568be81868ff850f8e25d33fce627c53dc861c6c
parent44181baf0472675a5474c14925dff678c0c1773a (diff)
downloadraylib-559b9b8cc36883670e5591fdc03cee2f0452fdf1.tar.gz
raylib-559b9b8cc36883670e5591fdc03cee2f0452fdf1.zip
Corrected possible memory leak
-rw-r--r--src/text.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/text.c b/src/text.c
index b553f0de..9755ff8b 100644
--- a/src/text.c
+++ b/src/text.c
@@ -311,6 +311,7 @@ Font LoadFontEx(const char *fileName, int fontSize, int charsCount, int *fontCha
{
Font spriteFont = { 0 };
int totalChars = 95; // Default charset [32..126]
+ bool fontCharsLoaded = false;
#if defined(SUPPORT_FILEFORMAT_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));
for (int i = 0; i < totalChars; i++) fontChars[i] = i + 32; // Default first character: SPACE[32]
+ fontCharsLoaded = true;
}
spriteFont = LoadTTF(fileName, fontSize, totalChars, fontChars);
+
+ if (fontCharsLoaded) free(fontChars);
}
#endif