glamor: zero num_modifiers 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: cef12efc15 ("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>
This commit is contained in:
Emil Velikov 2018-04-02 16:41:19 +01:00 committed by Adam Jackson
parent b36a14c0b0
commit 150e4b12ad

View File

@ -640,31 +640,27 @@ glamor_get_modifiers(ScreenPtr screen, CARD32 format,
struct glamor_egl_screen_private *glamor_egl; struct glamor_egl_screen_private *glamor_egl;
EGLint num; EGLint num;
/* Explicitly zero the count as the caller may ignore the return value */
*num_modifiers = 0;
glamor_egl = glamor_egl_get_screen_private(xf86ScreenToScrn(screen)); glamor_egl = glamor_egl_get_screen_private(xf86ScreenToScrn(screen));
if (!glamor_egl->dmabuf_capable) if (!glamor_egl->dmabuf_capable)
return FALSE; return FALSE;
if (!eglQueryDmaBufModifiersEXT(glamor_egl->display, format, 0, NULL, if (!eglQueryDmaBufModifiersEXT(glamor_egl->display, format, 0, NULL,
NULL, &num)) { NULL, &num))
*num_modifiers = 0;
return FALSE; return FALSE;
}
if (num == 0) { if (num == 0)
*num_modifiers = 0;
return TRUE; return TRUE;
}
*modifiers = calloc(num, sizeof(uint64_t)); *modifiers = calloc(num, sizeof(uint64_t));
if (*modifiers == NULL) { if (*modifiers == NULL)
*num_modifiers = 0;
return FALSE; return FALSE;
}
if (!eglQueryDmaBufModifiersEXT(glamor_egl->display, format, num, if (!eglQueryDmaBufModifiersEXT(glamor_egl->display, format, num,
(EGLuint64KHR *) *modifiers, NULL, &num)) { (EGLuint64KHR *) *modifiers, NULL, &num)) {
*num_modifiers = 0;
free(*modifiers); free(*modifiers);
return FALSE; return FALSE;
} }