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

Wayland Backend: fix crash due to steam notifications #1697

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 35 additions & 2 deletions src/Backends/WaylandBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,40 @@ namespace gamescope
return outState;
}


inline bool BPlaneHasValidGeometry(const std::optional<WaylandPlaneState> &oState)
{
// valid values for:
// - src:
// width & height: -1 or > 0
// x & y: -1 or >= 0
// - dst:
// width & height: -1 or > 0
// x & y: INT_MIN to INT_MAX (no restriction)
//
// For our purposes, we won't treat src{X,Y,Width,Height} or
// dst{Width,Height} values of -1 as valid Since we'll never set those
// aforementioned geometry components to -1 while still intending to
// present the plane
if (!oState) {
return false;
}
const double epsilon = 0.001; // same epsilon value used in close_enough()
const double slightlyAboveZero = 0.0 + epsilon; // avoid any possible floating point comparison weirdness
if (oState->flSrcX < 0.0 || oState->flSrcY < 0.0
|| oState->flSrcWidth < slightlyAboveZero
|| oState->flSrcHeight < slightlyAboveZero)
{
return false;
}

if (oState->nDstWidth <= 0 || oState->nDstHeight <= 0)
{
return false;
}
return true;
}

static int CreateShmBuffer( uint32_t uSize, void *pData )
{
char szShmBufferPath[ PATH_MAX ];
Expand Down Expand Up @@ -1344,7 +1378,7 @@ namespace gamescope
m_oCurrentPlaneState = oState;
}

if ( oState )
if ( BPlaneHasValidGeometry(oState) )
{
assert( oState->pBuffer );

Expand Down Expand Up @@ -1383,7 +1417,6 @@ namespace gamescope
break;
}
}

// Fraction with denominator of 120 per. spec
const uint32_t uScale = oState->uFractionalScale;

Expand Down
Loading