avutil/hwcontext: Don't assume frames_uninit is reentrant
Fix heap use after free when vulkan_frames_init failed. Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
This commit is contained in:
@@ -359,7 +359,7 @@ int av_hwframe_ctx_init(AVBufferRef *ref)
|
|||||||
if (ctx->internal->hw_type->frames_init) {
|
if (ctx->internal->hw_type->frames_init) {
|
||||||
ret = ctx->internal->hw_type->frames_init(ctx);
|
ret = ctx->internal->hw_type->frames_init(ctx);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto fail;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->internal->pool_internal && !ctx->pool)
|
if (ctx->internal->pool_internal && !ctx->pool)
|
||||||
@@ -369,14 +369,10 @@ int av_hwframe_ctx_init(AVBufferRef *ref)
|
|||||||
if (ctx->initial_pool_size > 0) {
|
if (ctx->initial_pool_size > 0) {
|
||||||
ret = hwframe_pool_prealloc(ref);
|
ret = hwframe_pool_prealloc(ref);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto fail;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
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,
|
int av_hwframe_transfer_get_formats(AVBufferRef *hwframe_ref,
|
||||||
|
|||||||
Reference in New Issue
Block a user