mirror of
https://github.com/raysan5/raylib.git
synced 2026-04-26 08:37:25 -04:00
Fix memory leak in LoadGLTF when model has no bones (#5629)
Co-authored-by: Victor <victor@localhost.localdomain>
This commit is contained in:
@ -5511,8 +5511,10 @@ static Model LoadGLTF(const char *fileName)
|
|||||||
|
|
||||||
if (dracoCompression)
|
if (dracoCompression)
|
||||||
{
|
{
|
||||||
return model;
|
|
||||||
TRACELOG(LOG_WARNING, "MODEL: [%s] Failed to load glTF data", fileName);
|
TRACELOG(LOG_WARNING, "MODEL: [%s] Failed to load glTF data", fileName);
|
||||||
|
cgltf_free(data);
|
||||||
|
UnloadFileData(fileData);
|
||||||
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACELOG(LOG_DEBUG, " > Primitives (triangles only) count based on hierarchy : %i", primitivesCount);
|
TRACELOG(LOG_DEBUG, " > Primitives (triangles only) count based on hierarchy : %i", primitivesCount);
|
||||||
@ -6334,6 +6336,14 @@ static Model LoadGLTF(const char *fileName)
|
|||||||
for (int j = 0; j < model.skeleton.boneCount; j++) model.boneMatrices[j] = MatrixIdentity();
|
for (int j = 0; j < model.skeleton.boneCount; j++) model.boneMatrices[j] = MatrixIdentity();
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
if (model.skeleton.boneCount == 0)
|
||||||
|
{
|
||||||
|
RL_FREE(model.currentPose);
|
||||||
|
RL_FREE(model.boneMatrices);
|
||||||
|
model.currentPose = NULL;
|
||||||
|
model.boneMatrices = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// Free all cgltf loaded data
|
// Free all cgltf loaded data
|
||||||
cgltf_free(data);
|
cgltf_free(data);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user