From 0fce96ddf92ba14065c0c4abd6e059868bef8a93 Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Mon, 23 Oct 2023 09:13:02 +0200 Subject: [PATCH] present: Check PresentOptionAsyncMayTear against capabilities The option PresentOptionAsyncMayTear is only supported by Xwayland for now, yet the Present supported version advertised is the same for all Xservers. So a client may try to use PresentOptionAsyncMayTear on a plain Xorg server and not get the expected result. Check that PresentCapabilityAsyncMayTear is advertised if the client specifies PresentOptionAsyncMayTear in the present options, and fail with a BadValue error otherwise. Signed-off-by: Olivier Fourdan --- present/present.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/present/present.c b/present/present.c index 6fb73901e..20658b94a 100644 --- a/present/present.c +++ b/present/present.c @@ -245,6 +245,15 @@ present_pixmap(WindowPtr window, { ScreenPtr screen = window->drawable.pScreen; present_screen_priv_ptr screen_priv = present_screen_priv(screen); + uint32_t capabilities; + + /* Make sure the option PresentOptionAsyncMayTear, if passed by the client, + * is actually supported. + */ + capabilities = screen_priv->query_capabilities(screen_priv); + if ((options & PresentOptionAsyncMayTear) && + !(capabilities & PresentCapabilityAsyncMayTear)) + return BadValue; return screen_priv->present_pixmap(window, pixmap,