Skip to content

Backends: avoid null dereference in metal and osx shutdown#6385

Merged
ocornut merged 1 commit intoocornut:masterfrom
iRath96:fix-shutdown
May 4, 2023
Merged

Backends: avoid null dereference in metal and osx shutdown#6385
ocornut merged 1 commit intoocornut:masterfrom
iRath96:fix-shutdown

Conversation

@iRath96
Copy link
Copy Markdown
Contributor

@iRath96 iRath96 commented Apr 29, 2023

A recent change (7d40dd4) is causing a null pointer dereference on shutdown in the metal backend. This is because ImGui_ImplMetal_DestroyDeviceObjects tries to access BackendRendererUserData, which is set to nullptr before its execution. This PR changes the order so that the objects are destroyed before the pointer is set to null. Similarly, this PR fixes a memory leak on shutdown in the osx backend, where the pointer is also set to null before IM_DELETE is called. I have looked whether 7d40dd4 introduces issues in other backends as well, but metal and osx seem to be the only ones affected. Thanks!

@iRath96
Copy link
Copy Markdown
Contributor Author

iRath96 commented Apr 29, 2023

(For reference: #6334 is the original PR that introduced the offending commit)

@ocornut ocornut merged commit 70cca1e into ocornut:master May 4, 2023
@ocornut
Copy link
Copy Markdown
Owner

ocornut commented May 4, 2023

Apologies for overlooking this, thank you for the fix!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants