From: Emil Velikov <emil.veli...@collabora.com> 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 glamore + 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 <l...@collabora.com> Cc: Daniel Stone <dani...@collabora.com> Signed-off-by: Emil Velikov <emil.veli...@collabora.com> --- dri3/dri3_screen.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/dri3/dri3_screen.c b/dri3/dri3_screen.c index 628f7616e..ee23336a5 100644 --- a/dri3/dri3_screen.c +++ b/dri3/dri3_screen.c @@ -211,10 +211,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. -- 2.16.0 _______________________________________________ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel