diff mbox series

[FFmpeg-devel,2/5] avutil/hwcontext: Don't assume frames_uninit is reentrant

Message ID tencent_BD1781EE35753E27569B9D7CE0845AC03409@qq.com
State Accepted
Commit 3bb00c0a420c3ce83c6fafee30270d69622ccad7
Headers show
Series [FFmpeg-devel,1/5] avutil/hwcontext: Don't assume device_uninit is reentrant | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Zhao Zhili Feb. 20, 2024, 12:08 p.m. UTC
From: Zhao Zhili <zhilizhao@tencent.com>

Fix heap use after free when vulkan_frames_init failed.
---
 libavutil/hwcontext.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c
index e8c6256a73..dec8b84783 100644
--- a/libavutil/hwcontext.c
+++ b/libavutil/hwcontext.c
@@ -360,7 +360,7 @@  int av_hwframe_ctx_init(AVBufferRef *ref)
     if (ctx->internal->hw_type->frames_init) {
         ret = ctx->internal->hw_type->frames_init(ctx);
         if (ret < 0)
-            goto fail;
+            return ret;
     }
 
     if (ctx->internal->pool_internal && !ctx->pool)
@@ -370,14 +370,10 @@  int av_hwframe_ctx_init(AVBufferRef *ref)
     if (ctx->initial_pool_size > 0) {
         ret = hwframe_pool_prealloc(ref);
         if (ret < 0)
-            goto fail;
+            return ret;
     }
 
     return 0;
-fail:
-    if (ctx->internal->hw_type->frames_uninit)
-        ctx->internal->hw_type->frames_uninit(ctx);
-    return ret;
 }
 
 int av_hwframe_transfer_get_formats(AVBufferRef *hwframe_ref,