Skip to content

[rmodels] Ensure that GLTF buffers are deallocated before using them#4998

Closed
JeffM2501 wants to merge 1 commit intoraysan5:masterfrom
JeffM2501:gltf-dupe-buffer-leak
Closed

[rmodels] Ensure that GLTF buffers are deallocated before using them#4998
JeffM2501 wants to merge 1 commit intoraysan5:masterfrom
JeffM2501:gltf-dupe-buffer-leak

Conversation

@JeffM2501
Copy link
Contributor

Check to see if a mesh buffer is allocated before reallocating it so we don't leak that buffer in cases where the gltf may have duplicate attributes at different resolutions.

Should fix issue #4996

…we don't leak that buffer in cases where the gltf may have duplicate attributes at different resolutions.

Should fix issue raysan5#4996
@raysan5 raysan5 changed the title [RMODELS] Ensure that GLTF buffers are deallocated before using them. [rmodels] Ensure that GLTF buffers are deallocated before using them Jun 24, 2025
@raysan5
Copy link
Owner

raysan5 commented Jul 26, 2025

I'm afraid I'm not adding all those checks, two reasons:

  1. Users are the owners of data and should be careful with it
  2. If the pointers are freed but not zeroed, it will fail

@raysan5 raysan5 closed this Jul 26, 2025
@JeffM2501
Copy link
Contributor Author

we will have to make a different check then. This is a legitimate memory leak.
The other option is to skip loading the attribute if one of the same type has already been loaded.
but if we do not do anything the library will leak memory.
The duplicate attributes are added by the model exporters, and are not controllable by the end user, so raylib must deal with this situation in a valid way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants