Skip to content

Fix use-after-free in EglDisplay destructor when terminate() not called#123

Open
VladimirTechMan wants to merge 1 commit intogoogle:mainfrom
VladimirTechMan:main
Open

Fix use-after-free in EglDisplay destructor when terminate() not called#123
VladimirTechMan wants to merge 1 commit intogoogle:mainfrom
VladimirTechMan:main

Conversation

@VladimirTechMan
Copy link
Copy Markdown

m_contexts and m_surfaces hold objects whose destructors reference m_manager[]. The destructor body calls delete m_manager[] explicitly, but member variables are destroyed by C++ after the destructor body completes. If terminate() was never called, m_contexts and m_surfaces are still populated at that point, so their elements are destroyed after m_manager[] is already freed.

terminate() avoids this by clearing both maps while m_manager[] is still alive, but that only helps if it is actually called. Replicate the same clearing at the top of the destructor body so the fix applies regardless.

m_contexts and m_surfaces hold objects whose destructors reference
m_manager[]. The destructor body calls `delete m_manager[]` explicitly,
but member variables are destroyed by C++ after the destructor body
completes. If terminate() was never called, m_contexts and m_surfaces
are still populated at that point, so their elements are destroyed after
m_manager[] is already freed.

terminate() avoids this by clearing both maps while m_manager[] is still
alive, but that only helps if it is actually called. Replicate the same
clearing at the top of the destructor body so the fix applies regardless.

Signed-off-by: VladimirTechMan <1228301+VladimirTechMan@users.noreply.github.com>
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.

1 participant