Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rtextures] LoadTextureCubemap(): Copy image before generating mipmaps, to avoid dangling re-allocated pointers #4439

Merged
merged 1 commit into from
Oct 26, 2024

Conversation

Not-Nik
Copy link
Contributor

@Not-Nik Not-Nik commented Oct 26, 2024

LoadTextureCubemap(), takes image as a copy, not a reference.ImageMipmaps() re-allocates the data pointer of an image, making the old pointer invalid. This means that calls to LoadTextureCubemap() would almost always render the image unusable, resulting in a use-after-free bug, e.g. when unloading the image.

My apologies, fixup for #4429

@raysan5 raysan5 merged commit 38cf9f3 into raysan5:master Oct 26, 2024
14 checks passed
@raysan5
Copy link
Owner

raysan5 commented Oct 26, 2024

@Not-Nik thanks for the review. Did you verify the models_skybox artifacts on the corners?

@Not-Nik
Copy link
Contributor Author

Not-Nik commented Oct 26, 2024

Yes, both with and without HDR works for me!

psxdev pushed a commit to raylib4Consoles/raylib that referenced this pull request Nov 18, 2024
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