gl-renderer: Fix possible memory leak when no dmabuf modifers are supported

Some drivers support EGL_EXT_image_dma_buf_import_modifiers for format
enumeration, but don't have any modifiers. In this case, on platforms where
malloc(0) returns non-NULL, we would leak that allocation to the caller.

Handle this by noticing when the number of supported modifiers is 0 and
returning early.
dev
Adam Jackson 5 years ago committed by Pekka Paalanen
parent 95efe82982
commit 570490cef5
  1. 3
      libweston/renderer-gl/gl-renderer.c

@ -2424,7 +2424,8 @@ gl_renderer_query_dmabuf_modifiers(struct weston_compositor *wc, int format,
if (!gr->has_dmabuf_import_modifiers ||
!gr->query_dmabuf_modifiers(gr->egl_display, format, 0, NULL,
NULL, &num)) {
NULL, &num) ||
num == 0) {
*num_modifiers = 0;
return;
}

Loading…
Cancel
Save