History

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

Kacper Michajłow committed 1 year ago

Commit f00a08c1 parent c85a7481 file · +4 −2Browse files

Unified · Split

libavutil/hwcontext_amf.c+4−2
@@ -339,7 +339,7 @@ static int amf_transfer_data_from(AVHWFramesContext *ctx, AVFrame *dst, · 338 unmodified lines
339339 static void amf_device_uninit(AVHWDeviceContext *device_ctx)
340340 {
341341 AVAMFDeviceContext *amf_ctx = device_ctx->hwctx;
342− AMF_RESULT res;
342+ AMF_RESULT res = AMF_NOT_INITIALIZED;
343343 AMFTrace *trace;
344344
345345 if (amf_ctx->context) {
@@ -348,7 +348,9 @@ static void amf_device_uninit(AVHWDeviceContext *device_ctx) · 2 unmodified lines
348348 amf_ctx->context = NULL;
349349 }
350350
351− res = amf_ctx->factory->pVtbl->GetTrace(amf_ctx->factory, &trace);
351+ if (amf_ctx->factory)
352+ res = amf_ctx->factory->pVtbl->GetTrace(amf_ctx->factory, &trace);
353+
352354 if (res == AMF_OK) {
353355 trace->pVtbl->UnregisterWriter(trace, FFMPEG_AMF_WRITER_ID);
354356 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t