mirror of
https://github.com/hyprwm/Hyprland
synced 2024-12-22 19:49:49 +01:00
core: fix a few ubsan issues reported at exit of hyprland (#6699)
* watchdog: dont detach and cause race condition instead of detaching and causing a race condition on destruction where the thread is alive and watchdog has been destroyed, check if its joinable and join it on destruction. causes heap use after free on exit of compositor. * render: add checks for compositor shutting down avoid member call on null pointer, if the g_pHyprRenderer is destroyed we can call the member makeEGLCurrent on it, causes undefined behaviour on destruction of the compositor/hyprrenderer. found with ubsan.
This commit is contained in:
parent
f2dc48d92f
commit
ac11771348
3 changed files with 5 additions and 5 deletions
|
@ -7,7 +7,9 @@ CWatchdog::~CWatchdog() {
|
|||
m_bExitThread = true;
|
||||
m_bNotified = true;
|
||||
m_cvWatchdogCondition.notify_all();
|
||||
m_pWatchdog.reset();
|
||||
|
||||
if (m_pWatchdog && m_pWatchdog->joinable())
|
||||
m_pWatchdog->join();
|
||||
}
|
||||
|
||||
CWatchdog::CWatchdog() {
|
||||
|
@ -33,8 +35,6 @@ CWatchdog::CWatchdog() {
|
|||
m_bNotified = false;
|
||||
}
|
||||
});
|
||||
|
||||
m_pWatchdog->detach();
|
||||
}
|
||||
|
||||
void CWatchdog::startWatching() {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <dlfcn.h>
|
||||
|
||||
CRenderbuffer::~CRenderbuffer() {
|
||||
if (!g_pCompositor)
|
||||
if (!g_pCompositor || g_pCompositor->m_bIsShuttingDown || !g_pHyprRenderer)
|
||||
return;
|
||||
|
||||
g_pHyprRenderer->makeEGLCurrent();
|
||||
|
|
|
@ -9,7 +9,7 @@ CTexture::CTexture() {
|
|||
}
|
||||
|
||||
CTexture::~CTexture() {
|
||||
if (m_bNonOwning)
|
||||
if (m_bNonOwning || !g_pCompositor || g_pCompositor->m_bIsShuttingDown || !g_pHyprRenderer)
|
||||
return;
|
||||
|
||||
g_pHyprRenderer->makeEGLCurrent();
|
||||
|
|
Loading…
Reference in a new issue