From 362d421dc05685ed27a4f164185658e2ca760c5b Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Wed, 13 Mar 2024 12:48:53 +0900 Subject: [PATCH] linux_dmabuf: Fix dereferencing null pointer Change-Id: I6d2b28fd4430c3ef032a30282fddc760f9de1b21 --- src/client_buffer/linux_dmabuf_v1.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/client_buffer/linux_dmabuf_v1.c b/src/client_buffer/linux_dmabuf_v1.c index 88769ab..1321010 100644 --- a/src/client_buffer/linux_dmabuf_v1.c +++ b/src/client_buffer/linux_dmabuf_v1.c @@ -540,12 +540,15 @@ ds_linux_dmabuf_v1_create(struct wl_display *display, return linux_dmabuf; failed: - for (i = 0; i < linux_dmabuf->num_formats; i++) { - if (linux_dmabuf->supported_formats[i].modifiers) - free(linux_dmabuf->supported_formats[i].modifiers); + if (linux_dmabuf->supported_formats) { + for (i = 0; i < linux_dmabuf->num_formats; i++) { + if (linux_dmabuf->supported_formats[i].modifiers) + free(linux_dmabuf->supported_formats[i].modifiers); + } + + free(linux_dmabuf->supported_formats); } - free(linux_dmabuf->supported_formats); free(linux_dmabuf); return NULL; -- 2.7.4