Skip to content

Commit

Permalink
[rmodels] Fix leaks in LoadIQM() and LoadModelAnimationsIQM() (#4649)
Browse files Browse the repository at this point in the history
Add calls to UnloadFileData() before return in cases of invalid IQM file.
  • Loading branch information
peter15914 authored Dec 29, 2024
1 parent f355d6f commit d1315e8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/rmodels.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit d1315e8

Please sign in to comment.