diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c index 70c556ecac..745016ed7e 100644 --- a/libavutil/hwcontext.c +++ b/libavutil/hwcontext.c @@ -646,6 +646,9 @@ int av_hwdevice_ctx_create_derived(AVBufferRef **dst_ref_ptr, ret = AVERROR(ENOMEM); goto fail; } + ret = av_hwdevice_ctx_init(dst_ref); + if (ret < 0) + goto fail; goto done; } if (ret != AVERROR(ENOSYS)) @@ -658,10 +661,6 @@ int av_hwdevice_ctx_create_derived(AVBufferRef **dst_ref_ptr, goto fail; done: - ret = av_hwdevice_ctx_init(dst_ref); - if (ret < 0) - goto fail; - *dst_ref_ptr = dst_ref; return 0;