Commit 82aa88c8 authored by Marek Olšák's avatar Marek Olšák

gbm: don't pass invalid arguments to gbm_surface_create_with_modifiers

if num_modifiers is 0, modifiers has to be NULL.
Reviewed-by: Emil Velikov's avatarEmil Velikov <emil.velikov@collabora.com>
parent 737e7850
Pipeline #135321 passed with stages
in 1 minute and 32 seconds
......@@ -83,7 +83,7 @@ wgbm_window_init(struct wgbm_window *self,
if (dpy->wegl.EXT_image_dma_buf_import_modifiers &&
plat->gbm_surface_create_with_modifiers) {
EGLint num_modifiers = 0;
uint64_t *modifiers;
uint64_t *modifiers = NULL;
if (!plat->wegl.eglQueryDmaBufModifiersEXT(dpy->wegl.egl, format,
0, NULL,
......@@ -93,14 +93,17 @@ wgbm_window_init(struct wgbm_window *self,
return false;
}
modifiers = wcore_calloc(num_modifiers * sizeof(*modifiers));
if (!plat->wegl.eglQueryDmaBufModifiersEXT(dpy->wegl.egl, format,
num_modifiers, modifiers,
NULL, &num_modifiers)) {
wcore_errorf(WAFFLE_ERROR_UNKNOWN,
"eglQueryDmaBufModifiersEXT failed");
free(modifiers);
return false;
if (num_modifiers) {
modifiers = wcore_calloc(num_modifiers * sizeof(*modifiers));
if (!plat->wegl.eglQueryDmaBufModifiersEXT(dpy->wegl.egl, format,
num_modifiers, modifiers,
NULL, &num_modifiers)) {
wcore_errorf(WAFFLE_ERROR_UNKNOWN,
"eglQueryDmaBufModifiersEXT failed");
free(modifiers);
return false;
}
}
self->gbm_surface =
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment