screencopy: fix crash in screensharing toplevel with invalid handle (#13781)

This commit is contained in:
ssareta 2026-03-20 10:04:52 +13:00 committed by GitHub
parent 3b902a47fe
commit b940b0d2c1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 0 deletions

View file

@ -9,10 +9,16 @@
using namespace Screenshare;
CScreenshareSession::CScreenshareSession(PHLMONITOR monitor, wl_client* client) : m_type(SHARE_MONITOR), m_monitor(monitor), m_client(client) {
if UNLIKELY (!m_monitor)
return;
init();
}
CScreenshareSession::CScreenshareSession(PHLWINDOW window, wl_client* client) : m_type(SHARE_WINDOW), m_window(window), m_client(client) {
if UNLIKELY (!m_window)
return;
m_listeners.windowDestroyed = m_window->m_events.unmap.listen([this]() { stop(); });
m_listeners.windowSizeChanged = m_window->m_events.resize.listen([this]() {
calculateConstraints();
@ -34,6 +40,9 @@ CScreenshareSession::CScreenshareSession(PHLWINDOW window, wl_client* client) :
CScreenshareSession::CScreenshareSession(PHLMONITOR monitor, CBox captureRegion, wl_client* client) :
m_type(SHARE_REGION), m_monitor(monitor), m_captureBox(captureRegion), m_client(client) {
if UNLIKELY (!m_monitor)
return;
init();
}

View file

@ -26,6 +26,11 @@ CToplevelExportClient::CToplevelExportClient(SP<CHyprlandToplevelExportManagerV1
}
void CToplevelExportClient::captureToplevel(uint32_t frame, int32_t overlayCursor_, PHLWINDOW handle) {
if UNLIKELY (!handle) {
LOGM(Log::ERR, "Couldn't capture (window doesn't exist)");
return;
}
auto session = Screenshare::mgr()->getManagedSession(m_resource->client(), handle);
// create a frame