From 5787ce04bc5cb65e1b5b57cb58126a1c009b7eff Mon Sep 17 00:00:00 2001 From: Robert Mader Date: Sat, 21 Aug 2021 15:43:44 +0000 Subject: [PATCH] Bug 1726807 - Assert on valid wp_viewport values, r=gfx-reviewers,mstange Submitting invalid values to the Wayland compositor will trigger a protocol error, which in turn will trigger an unhandled crash. In order to create crash reports in such cases, assert on valid values in such cases. In the long run we can replace this with a general Wayland protocol error handler. Differential Revision: https://phabricator.services.mozilla.com/D123286 --- gfx/layers/NativeLayerWayland.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gfx/layers/NativeLayerWayland.cpp b/gfx/layers/NativeLayerWayland.cpp index 48414df6dd1b..e6b4c7703f98 100644 --- a/gfx/layers/NativeLayerWayland.cpp +++ b/gfx/layers/NativeLayerWayland.cpp @@ -683,6 +683,11 @@ void NativeLayerWayland::SetViewportSourceRect(const Rect aSourceRect) { } mViewportSourceRect = aSourceRect; + MOZ_RELEASE_ASSERT( + (mViewportSourceRect.x >= 0 && mViewportSourceRect.y >= 0 && + mViewportSourceRect.width > 0 && mViewportSourceRect.height > 0) || + (mViewportSourceRect.x == -1 && mViewportSourceRect.y == -1 && + mViewportSourceRect.width == -1 && mViewportSourceRect.height == -1)); wp_viewport_set_source(mViewport, wl_fixed_from_double(mViewportSourceRect.x), wl_fixed_from_double(mViewportSourceRect.y), wl_fixed_from_double(mViewportSourceRect.width), @@ -699,6 +704,10 @@ void NativeLayerWayland::SetViewportDestinationSize(int aWidth, int aHeight) { mViewportDestinationSize.width = aWidth; mViewportDestinationSize.height = aHeight; + MOZ_RELEASE_ASSERT((mViewportDestinationSize.width > 0 && + mViewportDestinationSize.height > 0) || + (mViewportDestinationSize.width == -1 && + mViewportDestinationSize.height == -1)); wp_viewport_set_destination(mViewport, mViewportDestinationSize.width, mViewportDestinationSize.height); }