You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
avutil/hwcontext_amf: fix crash on uninit after init failed
amf_device_create() calls amf_device_uninit() on errors, but if things were not initialized it will null deref amf_ctx->factory. Fixes: https://github.com/mpv-player/mpv/issues/15814 Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
This commit is contained in:
committed by
Dmitrii Ovchinnikov
parent
c85a748979
commit
f00a08c0ce
@@ -339,7 +339,7 @@ static int amf_transfer_data_from(AVHWFramesContext *ctx, AVFrame *dst,
|
|||||||
static void amf_device_uninit(AVHWDeviceContext *device_ctx)
|
static void amf_device_uninit(AVHWDeviceContext *device_ctx)
|
||||||
{
|
{
|
||||||
AVAMFDeviceContext *amf_ctx = device_ctx->hwctx;
|
AVAMFDeviceContext *amf_ctx = device_ctx->hwctx;
|
||||||
AMF_RESULT res;
|
AMF_RESULT res = AMF_NOT_INITIALIZED;
|
||||||
AMFTrace *trace;
|
AMFTrace *trace;
|
||||||
|
|
||||||
if (amf_ctx->context) {
|
if (amf_ctx->context) {
|
||||||
@@ -348,7 +348,9 @@ static void amf_device_uninit(AVHWDeviceContext *device_ctx)
|
|||||||
amf_ctx->context = NULL;
|
amf_ctx->context = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = amf_ctx->factory->pVtbl->GetTrace(amf_ctx->factory, &trace);
|
if (amf_ctx->factory)
|
||||||
|
res = amf_ctx->factory->pVtbl->GetTrace(amf_ctx->factory, &trace);
|
||||||
|
|
||||||
if (res == AMF_OK) {
|
if (res == AMF_OK) {
|
||||||
trace->pVtbl->UnregisterWriter(trace, FFMPEG_AMF_WRITER_ID);
|
trace->pVtbl->UnregisterWriter(trace, FFMPEG_AMF_WRITER_ID);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user