瀏覽代碼

Fix memory leak in LoadGLTF when model has no bones

pull/5629/head
Victor 1 周之前
父節點
當前提交
8cef7be939
共有 1 個文件被更改,包括 11 次插入1 次删除
  1. +11
    -1
      src/rmodels.c

+ 11
- 1
src/rmodels.c 查看文件

@ -5511,8 +5511,10 @@ static Model LoadGLTF(const char *fileName)
if (dracoCompression)
{
return model;
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);
@ -6334,6 +6336,14 @@ static Model LoadGLTF(const char *fileName)
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
cgltf_free(data);
}

Loading…
取消
儲存