From a39cde9d08a0b5d1decb549dc016c0b491cdb124 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Tue, 19 Apr 2016 12:18:58 -0700 Subject: [PATCH] obs-qsv11: Fix win7 crash when fake monitor isn't forced When using QSV is used on a windows 7 machine with a dedicated card, you have to fake a monitor connection to your Intel graphics to be able to use QSV. If you do not, the initialization will fail with an error. The error for that situation is not handled properly, and a variable will be used while null. Instead, the function should safely return after that error is received. Also, do not call ClearData in the destructor unless QSV has been properly initialized (if m_pmfxENC is null). --- plugins/obs-qsv11/QSV_Encoder_Internal.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/obs-qsv11/QSV_Encoder_Internal.cpp b/plugins/obs-qsv11/QSV_Encoder_Internal.cpp index 99e4fcec9..c73838b6e 100644 --- a/plugins/obs-qsv11/QSV_Encoder_Internal.cpp +++ b/plugins/obs-qsv11/QSV_Encoder_Internal.cpp @@ -126,7 +126,8 @@ QSV_Encoder_Internal::QSV_Encoder_Internal(mfxIMPL& impl, mfxVersion& version) : QSV_Encoder_Internal::~QSV_Encoder_Internal() { - ClearData(); + if (m_pmfxENC) + ClearData(); } mfxStatus QSV_Encoder_Internal::Open(qsv_param_t * pParams) @@ -140,8 +141,9 @@ mfxStatus QSV_Encoder_Internal::Open(qsv_param_t * pParams) // Use system memory sts = Initialize(m_impl, m_ver, &m_session, NULL); - if (sts == MFX_ERR_NONE) - m_pmfxENC = new MFXVideoENCODE(m_session); + MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts); + + m_pmfxENC = new MFXVideoENCODE(m_session); InitParams(pParams);