From d1315e8a0429e9b43b80b705199d5fec4ee5a83b Mon Sep 17 00:00:00 2001 From: Peter Zmanovsky <48548636+peter15914@users.noreply.github.com> Date: Mon, 30 Dec 2024 01:06:40 +0500 Subject: [PATCH] [rmodels] Fix leaks in LoadIQM() and LoadModelAnimationsIQM() (#4649) Add calls to UnloadFileData() before return in cases of invalid IQM file. --- src/rmodels.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/rmodels.c b/src/rmodels.c index c62267de4733..70e461ea5222 100644 --- a/src/rmodels.c +++ b/src/rmodels.c @@ -4570,12 +4570,14 @@ static Model LoadIQM(const char *fileName) if (memcmp(iqmHeader->magic, IQM_MAGIC, sizeof(IQM_MAGIC)) != 0) { TRACELOG(LOG_WARNING, "MODEL: [%s] IQM file is not a valid model", fileName); + UnloadFileData(fileData); return model; } if (iqmHeader->version != IQM_VERSION) { TRACELOG(LOG_WARNING, "MODEL: [%s] IQM file version not supported (%i)", fileName, iqmHeader->version); + UnloadFileData(fileData); return model; } @@ -4891,12 +4893,14 @@ static ModelAnimation *LoadModelAnimationsIQM(const char *fileName, int *animCou if (memcmp(iqmHeader->magic, IQM_MAGIC, sizeof(IQM_MAGIC)) != 0) { TRACELOG(LOG_WARNING, "MODEL: [%s] IQM file is not a valid model", fileName); + UnloadFileData(fileData); return NULL; } if (iqmHeader->version != IQM_VERSION) { TRACELOG(LOG_WARNING, "MODEL: [%s] IQM file version not supported (%i)", fileName, iqmHeader->version); + UnloadFileData(fileData); return NULL; }