From d5117961b408778e0135131aa77d665841515a58 Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Thu, 22 Feb 2024 23:07:58 +0100 Subject: [PATCH] render/vulkan: Avoid double-free on calloc error In query_modifier_support, the calloc for either or both of render_mods and texture_mods may fail, in which case both are freed for convenience. However, if one is non-NULL, vulkan_format_props_finish will try to free it again. NULL them to avoid double-free. (cherry picked from commit 4d68d3759b92f9192ced0dc9ed2572c33e894a7b) --- render/vulkan/pixel_format.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/render/vulkan/pixel_format.c b/render/vulkan/pixel_format.c index ced6eb24f..f91f92d9f 100644 --- a/render/vulkan/pixel_format.c +++ b/render/vulkan/pixel_format.c @@ -343,6 +343,8 @@ static bool query_modifier_support(struct wlr_vk_device *dev, free(modp.pDrmFormatModifierProperties); free(props->dmabuf.render_mods); free(props->dmabuf.texture_mods); + props->dmabuf.render_mods = NULL; + props->dmabuf.texture_mods = NULL; return false; }