diff options
author | Michel Dänzer <mdaenzer@redhat.com> | 2024-04-11 11:42:51 +0200 |
---|---|---|
committer | Olivier Fourdan <ofourdan@redhat.com> | 2024-05-03 10:30:56 +0200 |
commit | 05150863c6fc98fbdd2d0f28f9ff6c5e994b44d9 (patch) | |
tree | 9c9366d9485bdf4dc8e3a904fcf6010eb634b57d | |
parent | fc3b7c9ad89b5bd7b3deafb3a92af0f2aaa34964 (diff) |
dri3: Free formats in cache_formats_and_modifiers
Fixes leak:
==15672== 60 bytes in 1 blocks are definitely lost in loss record 3,803 of 8,127
==15672== at 0x4840718: malloc (vg_replace_malloc.c:392)
==15672== by 0x2F2698: XNFreallocarray (alloc.c:55)
==15672== by 0x1ADAA9: xwl_dmabuf_get_formats_for_device (xwayland-dmabuf.c:207)
==15672== by 0x1ADAA9: xwl_glamor_get_formats (xwayland-dmabuf.c:248)
==15672== by 0x303D86: cache_formats_and_modifiers (dri3_screen.c:176)
==15672== by 0x303D86: dri3_get_supported_modifiers (dri3_screen.c:229)
==15672== by 0x30331A: proc_dri3_get_supported_modifiers (dri3_request.c:389)
==15672== by 0x217B6B: Dispatch (dispatch.c:550)
==15672== by 0x21B9A0: dix_main (main.c:276)
==15672== by 0x51086C9: (below main) (libc_start_call_main.h:58)
Fixes: a42992a4cca4 ("dri3: rework format/modifier caching")
(cherry picked from commit 3b6b88c184ddbe41ddab91a543e08fddcef14481)
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1515>
-rw-r--r-- | dri3/dri3_screen.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/dri3/dri3_screen.c b/dri3/dri3_screen.c index bc96e5339..ebdaaafa1 100644 --- a/dri3/dri3_screen.c +++ b/dri3/dri3_screen.c @@ -183,8 +183,10 @@ cache_formats_and_modifiers(ScreenPtr screen) } ds->formats = calloc(num_formats, sizeof(dri3_dmabuf_format_rec)); - if (!ds->formats) + if (!ds->formats) { + free(formats); return BadAlloc; + } for (i = 0; i < num_formats; i++) { dri3_dmabuf_format_ptr iter = &ds->formats[i]; @@ -205,6 +207,7 @@ cache_formats_and_modifiers(ScreenPtr screen) ds->num_formats = i; ds->formats_cached = TRUE; + free(formats); return Success; } |