Skip to content

Commit

Permalink
GLTF: fix segfault in animNormals memcpy when mesh.normals == NULL (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-l authored Jun 10, 2023
1 parent 6aada7d commit 2e00d16
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/rmodels.c
Original file line number Diff line number Diff line change
Expand Up @@ -5201,7 +5201,9 @@ static Model LoadGLTF(const char *fileName)
model.meshes[meshIndex].animVertices = RL_CALLOC(model.meshes[meshIndex].vertexCount*3, sizeof(float));
memcpy(model.meshes[meshIndex].animVertices, model.meshes[meshIndex].vertices, model.meshes[meshIndex].vertexCount*3*sizeof(float));
model.meshes[meshIndex].animNormals = RL_CALLOC(model.meshes[meshIndex].vertexCount*3, sizeof(float));
memcpy(model.meshes[meshIndex].animNormals, model.meshes[meshIndex].normals, model.meshes[meshIndex].vertexCount*3*sizeof(float));
if (model.meshes[meshIndex].normals != NULL) {
memcpy(model.meshes[meshIndex].animNormals, model.meshes[meshIndex].normals, model.meshes[meshIndex].vertexCount*3*sizeof(float));
}

meshIndex++; // Move to next mesh
}
Expand Down

0 comments on commit 2e00d16

Please sign in to comment.