Re: [FFmpeg-devel] [PATCH v2 3/5] avutil/hwcontext_vulkan: Fix leaks when semaphore creation fails

2024-02-23 Thread Lynne
Feb 22, 2024, 15:43 by quinkbl...@foxmail.com:

> From: Zhao Zhili 
>
> ---
>  libavutil/hwcontext_vulkan.c | 27 +--
>  1 file changed, 17 insertions(+), 10 deletions(-)
>

LGTM on all Vulkan patches you posted.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v2 3/5] avutil/hwcontext_vulkan: Fix leaks when semaphore creation fails

2024-02-22 Thread Zhao Zhili
From: Zhao Zhili 

---
 libavutil/hwcontext_vulkan.c | 27 +--
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index d660f63afe..ee13788ead 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -1807,16 +1807,22 @@ static void vulkan_frame_free(AVHWFramesContext *hwfc, 
AVVkFrame *f)
 VulkanDevicePriv *p = hwfc->device_ctx->internal->priv;
 FFVulkanFunctions *vk = >vkctx.vkfn;
 int nb_images = ff_vk_count_images(f);
+int nb_sems = 0;
+
+while (nb_sems < FF_ARRAY_ELEMS(f->sem) && f->sem[nb_sems])
+nb_sems++;
+
+if (nb_sems) {
+VkSemaphoreWaitInfo sem_wait = {
+.sType  = VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO,
+.flags  = 0x0,
+.pSemaphores= f->sem,
+.pValues= f->sem_value,
+.semaphoreCount = nb_sems,
+};
 
-VkSemaphoreWaitInfo sem_wait = {
-.sType  = VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO,
-.flags  = 0x0,
-.pSemaphores= f->sem,
-.pValues= f->sem_value,
-.semaphoreCount = nb_images,
-};
-
-vk->WaitSemaphores(hwctx->act_dev, _wait, UINT64_MAX);
+vk->WaitSemaphores(hwctx->act_dev, _wait, UINT64_MAX);
+}
 
 vulkan_free_internal(f);
 
@@ -2098,7 +2104,8 @@ static int create_frame(AVHWFramesContext *hwfc, 
AVVkFrame **frame,
 if (ret != VK_SUCCESS) {
 av_log(hwctx, AV_LOG_ERROR, "Failed to create semaphore: %s\n",
ff_vk_ret2str(ret));
-return AVERROR_EXTERNAL;
+err = AVERROR_EXTERNAL;
+goto fail;
 }
 
 f->queue_family[i] = p->nb_img_qfs > 1 ? VK_QUEUE_FAMILY_IGNORED : 
p->img_qfs[0];
-- 
2.34.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".