summaryrefslogtreecommitdiff
path: root/dri3/dri3_screen.c
diff options
context:
space:
mode:
authorEmil Velikov <emil.velikov@collabora.com>2018-04-02 16:41:20 +0100
committerAdam Jackson <ajax@redhat.com>2018-04-10 15:42:40 -0400
commite2f45002fc3c53c6196935447b8fe77d0850175b (patch)
tree89443781b52bdb76d521ce24a1e0a6e7270637a8 /dri3/dri3_screen.c
parent150e4b12ad160b093899107ed586aa0cb258879e (diff)
dri3: check for ::get_drawable_modifiers failure
Currently if the function fails, we'll fall into two false assumptions: - the the count is zero - that the storage pointer is safe for free() I've just fixed the former (in glamor + xwayland) and have no plans on adding yet another workaround for the latter. Simply zero both variables. Regardless if the implementation is missing the callback or it foobars with output variables (normally a bad idea). Bonus points - this fixes a bug where we feed garbage to free() further down ;-) Fixes: cef12efc15c ("glamor: Implement GetSupportedModifiers") Cc: Louis-Francis Ratté-Boulianne <lfrb@collabora.com> Cc: Daniel Stone <daniels@collabora.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Diffstat (limited to 'dri3/dri3_screen.c')
-rw-r--r--dri3/dri3_screen.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/dri3/dri3_screen.c b/dri3/dri3_screen.c
index 1257c0ef4..a9d2e01db 100644
--- a/dri3/dri3_screen.c
+++ b/dri3/dri3_screen.c
@@ -253,10 +253,13 @@ dri3_get_supported_modifiers(ScreenPtr screen, DrawablePtr drawable,
return Success;
}
- if (info->get_drawable_modifiers)
- (*info->get_drawable_modifiers) (drawable, format,
- &num_drawable_mods,
- &drawable_mods);
+ if (!info->get_drawable_modifiers ||
+ !info->get_drawable_modifiers(drawable, format,
+ &num_drawable_mods,
+ &drawable_mods)) {
+ num_drawable_mods = 0;
+ drawable_mods = NULL;
+ }
/* We're allocating slightly more memory than necessary but it reduces
* the complexity of finding the intersection set.