From 80a0567a2f94b9f6c2cead99282c93fc601098d3 Mon Sep 17 00:00:00 2001 From: Lynne Date: Wed, 9 Oct 2024 02:37:26 +0200 Subject: [PATCH] vulkan: fix ImageView flexible array struct allocation Same as the previous commit, the compiler may insert padding. Thanks to Marvin Scholz for pointing this out. --- libavutil/vulkan.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavutil/vulkan.c b/libavutil/vulkan.c index 4a194ff082..9c5959f730 100644 --- a/libavutil/vulkan.c +++ b/libavutil/vulkan.c @@ -1324,8 +1324,9 @@ int ff_vk_create_imageviews(FFVulkanContext *s, FFVkExecContext *e, const int nb_images = ff_vk_count_images(vkf); const int nb_planes = av_pix_fmt_count_planes(hwfc->sw_format); - const size_t buf_size = sizeof(int) + nb_planes*sizeof(VkImageView); - ImageViewCtx *iv = av_mallocz(buf_size); + ImageViewCtx *iv; + const size_t buf_size = sizeof(*iv) + nb_planes*sizeof(VkImageView); + iv = av_mallocz(buf_size); if (!iv) return AVERROR(ENOMEM);