[FFmpeg-cvslog] vulkan: fix ImageView flexible array struct allocation

Lynne git at videolan.org
Wed Oct 9 03:40:11 EEST 2024


ffmpeg | branch: master | Lynne <dev at lynne.ee> | Wed Oct  9 02:37:26 2024 +0200| [80a0567a2f94b9f6c2cead99282c93fc601098d3] | committer: Lynne

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.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=80a0567a2f94b9f6c2cead99282c93fc601098d3
---

 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);
 



More information about the ffmpeg-cvslog mailing list