jkuhlmann / cgltf

:diamond_shape_with_a_dot_inside: Single-file glTF 2.0 loader and writer written in C99
MIT License
1.44k stars 136 forks source link

cgltf_free uses file release callback for base64 buffers #158

Closed pezcode closed 3 years ago

pezcode commented 3 years ago

cgltf_load_buffers loads base64-encoded buffers with the memory.alloc callback, but cgltf_free frees all buffers with file.release. This is incorrect for cases where memory.free actually frees memory but file.read doesn't (e.g. using static embedded files), leading to a memory leak.

jkuhlmann commented 3 years ago

I've added a change in PR #160 that allows the library to track where the buffer data comes from. Does that help in your case?

pezcode commented 3 years ago

Yep, that fixes it. Appreciate the timely fix!