summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmil Velikov <emil.velikov@collabora.com>2018-04-02 16:41:22 +0100
committerAdam Jackson <ajax@redhat.com>2018-04-10 15:42:40 -0400
commitac48724639e0a6a9e421b3b4e545d8506fd6bf5d (patch)
treeb7e7478e6e8571c5c2232690e4077518c85281bc
parente2f45002fc3c53c6196935447b8fe77d0850175b (diff)
xwayland: zero num_formats from the start
The caller may ignore the return value (will be addressed with later commit) so simply zero the count from the get-go. We're pretty much do so, in all cases but one :-\ 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>
-rw-r--r--hw/xwayland/xwayland-glamor.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index 59461be1f..1b9a6b030 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -750,19 +750,18 @@ glamor_get_formats(ScreenPtr screen,
struct xwl_screen *xwl_screen = xwl_screen_get(screen);
int i;
+ /* Explicitly zero the count as the caller may ignore the return value */
+ *num_formats = 0;
+
if (!xwl_screen->dmabuf_capable || !xwl_screen->dmabuf)
return FALSE;
- if (xwl_screen->num_formats == 0) {
- *num_formats = 0;
+ if (xwl_screen->num_formats == 0)
return TRUE;
- }
*formats = calloc(xwl_screen->num_formats, sizeof(CARD32));
- if (*formats == NULL) {
- *num_formats = 0;
+ if (*formats == NULL)
return FALSE;
- }
for (i = 0; i < xwl_screen->num_formats; i++)
(*formats)[i] = xwl_screen->formats[i].format;