From 0bc115790633404ef010fd9ec8a94482e5e317e8 Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Sun, 24 Nov 2013 22:40:39 +0100 Subject: [PATCH] Fixed a possible NULL-pointer access in DWMAPI wrapper code when DWM is not available. --- res/Images.qrc | 1 - src/Config.h | 2 +- src/Global_Win32.cpp | 61 +++++++++++++++++++++++++------------------- 3 files changed, 36 insertions(+), 28 deletions(-) diff --git a/res/Images.qrc b/res/Images.qrc index b6eb2678..b67b6db4 100644 --- a/res/Images.qrc +++ b/res/Images.qrc @@ -23,7 +23,6 @@ images/Logo_GNU.png images/Logo_Software.png images/Qt.svg - images/Splash.png images/Sound.png images/Starting.png images/Thumb.png diff --git a/src/Config.h b/src/Config.h index 0aec7e90..893420ef 100644 --- a/src/Config.h +++ b/src/Config.h @@ -35,7 +35,7 @@ #define VER_LAMEXP_MINOR_LO 9 #define VER_LAMEXP_TYPE Alpha #define VER_LAMEXP_PATCH 8 -#define VER_LAMEXP_BUILD 1470 +#define VER_LAMEXP_BUILD 1472 #define VER_LAMEXP_CONFG 1348 /////////////////////////////////////////////////////////////////////////////// diff --git a/src/Global_Win32.cpp b/src/Global_Win32.cpp index 4dd487af..e344be8b 100644 --- a/src/Global_Win32.cpp +++ b/src/Global_Win32.cpp @@ -173,10 +173,10 @@ g_lamexp_themes_enabled; static struct { bool bInitialized; - QLibrary *dwmapi_dll; HRESULT (__stdcall *dwmIsCompositionEnabled)(BOOL *bEnabled); HRESULT (__stdcall *dwmExtendFrameIntoClientArea)(HWND hWnd, const MARGINS* pMarInset); HRESULT (__stdcall *dwmEnableBlurBehindWindow)(HWND hWnd, const DWM_BLURBEHIND* pBlurBehind); + QLibrary *dwmapi_dll; QReadWriteLock lock; } g_lamexp_dwmapi; @@ -1858,14 +1858,14 @@ bool lamexp_open_media_file(const QString &mediaFilePath) return false; } -static bool lamexp_init_dwmapi(void) +static void lamexp_init_dwmapi(void) { QReadLocker writeLock(&g_lamexp_dwmapi.lock); //Not initialized yet? if(g_lamexp_dwmapi.bInitialized) { - return (g_lamexp_dwmapi.dwmIsCompositionEnabled != NULL); + return; } //Reset function pointers @@ -1893,7 +1893,6 @@ static bool lamexp_init_dwmapi(void) } g_lamexp_dwmapi.bInitialized = true; - return (g_lamexp_dwmapi.dwmIsCompositionEnabled != NULL); } /* @@ -1907,20 +1906,25 @@ bool lamexp_sheet_of_glass(QWidget *window) while(!g_lamexp_dwmapi.bInitialized) { readLock.unlock(); - if(!lamexp_init_dwmapi()) return false; + lamexp_init_dwmapi(); readLock.relock(); } - - //Check if composition is enabled - BOOL bEnabled = FALSE; - if(HRESULT hr = g_lamexp_dwmapi.dwmIsCompositionEnabled(&bEnabled)) - { - qWarning("DwmIsCompositionEnabled function has failed! (error %d)", hr); - return false; - } - //Composition enabled and required functions available? - if((!bEnabled) || (g_lamexp_dwmapi.dwmExtendFrameIntoClientArea == NULL) || (g_lamexp_dwmapi.dwmEnableBlurBehindWindow == NULL)) + BOOL bCompositionEnabled = FALSE; + + //Required functions available? + if((g_lamexp_dwmapi.dwmIsCompositionEnabled != NULL) && (g_lamexp_dwmapi.dwmExtendFrameIntoClientArea != NULL) && (g_lamexp_dwmapi.dwmEnableBlurBehindWindow != NULL)) + { + //Check if composition is currently enabled + if(HRESULT hr = g_lamexp_dwmapi.dwmIsCompositionEnabled(&bCompositionEnabled)) + { + qWarning("DwmIsCompositionEnabled function has failed! (error %d)", hr); + return false; + } + } + + //All functions available *and* composition enabled? + if(!bCompositionEnabled) { return false; } @@ -1963,20 +1967,25 @@ bool lamexp_sheet_of_glass_update(QWidget *window) while(!g_lamexp_dwmapi.bInitialized) { readLock.unlock(); - if(!lamexp_init_dwmapi()) return false; + lamexp_init_dwmapi(); readLock.relock(); } - - //Check if composition is enabled - BOOL bEnabled = FALSE; - if(HRESULT hr = g_lamexp_dwmapi.dwmIsCompositionEnabled(&bEnabled)) - { - qWarning("DwmIsCompositionEnabled function has failed! (error %d)", hr); - return false; - } - //Composition enabled and required functions available? - if((!bEnabled) || (g_lamexp_dwmapi.dwmEnableBlurBehindWindow == NULL)) + BOOL bCompositionEnabled = FALSE; + + //Required functions available? + if((g_lamexp_dwmapi.dwmIsCompositionEnabled != NULL) && (g_lamexp_dwmapi.dwmEnableBlurBehindWindow != NULL)) + { + //Check if composition is currently enabled + if(HRESULT hr = g_lamexp_dwmapi.dwmIsCompositionEnabled(&bCompositionEnabled)) + { + qWarning("DwmIsCompositionEnabled function has failed! (error %d)", hr); + return false; + } + } + + //All functions available *and* composition enabled? + if(!bCompositionEnabled) { return false; }