[FFmpeg-cvslog] hwcontext_d3d11va: properly reset values after release/close
Jan Ekström
git at videolan.org
Sat Nov 25 18:52:36 EET 2017
ffmpeg | branch: master | Jan Ekström <jeebjp at gmail.com> | Fri Nov 24 02:44:44 2017 +0200| [f6d49a0dc84aade2adf150c25afb66cbda1d5528] | committer: Jan Ekström
hwcontext_d3d11va: properly reset values after release/close
Makes the uninit function re-entrable, which can be a common case
when an API user first tries to initialize its context, fails, and
then finally unrefs the AVHWDevice.
Fixes a crash reported by sm2345 on IRC.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f6d49a0dc84aade2adf150c25afb66cbda1d5528
---
libavutil/hwcontext_d3d11va.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c
index 769c81fd77..2f97156a54 100644
--- a/libavutil/hwcontext_d3d11va.c
+++ b/libavutil/hwcontext_d3d11va.c
@@ -458,20 +458,31 @@ static void d3d11va_device_uninit(AVHWDeviceContext *hwdev)
{
AVD3D11VADeviceContext *device_hwctx = hwdev->hwctx;
- if (device_hwctx->device)
+ if (device_hwctx->device) {
ID3D11Device_Release(device_hwctx->device);
+ device_hwctx->device = NULL;
+ }
- if (device_hwctx->device_context)
+ if (device_hwctx->device_context) {
ID3D11DeviceContext_Release(device_hwctx->device_context);
+ device_hwctx->device_context = NULL;
+ }
- if (device_hwctx->video_device)
+ if (device_hwctx->video_device) {
ID3D11VideoDevice_Release(device_hwctx->video_device);
+ device_hwctx->video_device = NULL;
+ }
- if (device_hwctx->video_context)
+ if (device_hwctx->video_context) {
ID3D11VideoContext_Release(device_hwctx->video_context);
+ device_hwctx->video_context = NULL;
+ }
- if (device_hwctx->lock == d3d11va_default_lock)
+ if (device_hwctx->lock == d3d11va_default_lock) {
CloseHandle(device_hwctx->lock_ctx);
+ device_hwctx->lock_ctx = INVALID_HANDLE_VALUE;
+ device_hwctx->lock = NULL;
+ }
}
static int d3d11va_device_create(AVHWDeviceContext *ctx, const char *device,
More information about the ffmpeg-cvslog
mailing list