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

Fix memory overlap in cgltf_decode_string #166

Closed pezcode closed 2 years ago

pezcode commented 2 years ago

This fixes some undefined behaviour in cgltf_decode_string added in https://github.com/jkuhlmann/cgltf/pull/165. Overlapping memory in any of the str* functions turns out to be UB caught by ASan.

It might be worth adding target_link_libraries(${EXE_NAME} -fsanitize=address) to the test CMake targets to catch similar errors in the future.

jkuhlmann commented 2 years ago

Thanks for the address sanitizer idea! I've added that to all the tests now.