1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00

hwcontext_d3d11: Fix crash with valid adapter but no device

This crash was introduced by 8bbf2dacbf,
which could incorrectly overwrite the failure result from creating the
device.

Fixes ticket #7108.

Reviewed-by: wm4 <nfxjfg@googlemail.com>
This commit is contained in:
Mark Thompson 2018-03-27 00:04:32 +01:00
parent b3e9f3f5f5
commit 44000b7744

View File

@ -556,8 +556,6 @@ static int d3d11va_device_create(AVHWDeviceContext *ctx, const char *device,
}
}
hr = mD3D11CreateDevice(pAdapter, pAdapter ? D3D_DRIVER_TYPE_UNKNOWN : D3D_DRIVER_TYPE_HARDWARE, NULL, creationFlags, NULL, 0,
D3D11_SDK_VERSION, &device_hwctx->device, NULL, NULL);
if (pAdapter) {
DXGI_ADAPTER_DESC2 desc;
hr = IDXGIAdapter2_GetDesc(pAdapter, &desc);
@ -565,8 +563,12 @@ static int d3d11va_device_create(AVHWDeviceContext *ctx, const char *device,
av_log(ctx, AV_LOG_INFO, "Using device %04x:%04x (%ls).\n",
desc.VendorId, desc.DeviceId, desc.Description);
}
IDXGIAdapter_Release(pAdapter);
}
hr = mD3D11CreateDevice(pAdapter, pAdapter ? D3D_DRIVER_TYPE_UNKNOWN : D3D_DRIVER_TYPE_HARDWARE, NULL, creationFlags, NULL, 0,
D3D11_SDK_VERSION, &device_hwctx->device, NULL, NULL);
if (pAdapter)
IDXGIAdapter_Release(pAdapter);
if (FAILED(hr)) {
av_log(ctx, AV_LOG_ERROR, "Failed to create Direct3D device (%lx)\n", (long)hr);
return AVERROR_UNKNOWN;