Module: wine Branch: master Commit: 1ec8bf9b739f1528b742169670eac2350b33a7d4 URL: https://source.winehq.org/git/wine.git/?a=commit;h=1ec8bf9b739f1528b74216967...
Author: Zhiyi Zhang zzhang@codeweavers.com Date: Sat Aug 8 00:02:25 2020 +0800
dwmapi: Check NULL parameter in DwmIsCompositionEnabled().
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49664 Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
configure | 1 + configure.ac | 1 + dlls/dwmapi/dwmapi_main.c | 3 +++ dlls/dwmapi/tests/Makefile.in | 5 +++++ dlls/dwmapi/tests/dwmapi.c | 39 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 49 insertions(+)
diff --git a/configure b/configure index f2785a280f..c9afbc0ab8 100755 --- a/configure +++ b/configure @@ -20756,6 +20756,7 @@ wine_fn_config_makefile dlls/dsuiext enable_dsuiext wine_fn_config_makefile dlls/dswave enable_dswave wine_fn_config_makefile dlls/dswave/tests enable_tests wine_fn_config_makefile dlls/dwmapi enable_dwmapi +wine_fn_config_makefile dlls/dwmapi/tests enable_tests wine_fn_config_makefile dlls/dwrite enable_dwrite wine_fn_config_makefile dlls/dwrite/tests enable_tests wine_fn_config_makefile dlls/dx8vb enable_dx8vb diff --git a/configure.ac b/configure.ac index 0f4b0b817a..360ef2b11f 100644 --- a/configure.ac +++ b/configure.ac @@ -3278,6 +3278,7 @@ WINE_CONFIG_MAKEFILE(dlls/dsuiext) WINE_CONFIG_MAKEFILE(dlls/dswave) WINE_CONFIG_MAKEFILE(dlls/dswave/tests) WINE_CONFIG_MAKEFILE(dlls/dwmapi) +WINE_CONFIG_MAKEFILE(dlls/dwmapi/tests) WINE_CONFIG_MAKEFILE(dlls/dwrite) WINE_CONFIG_MAKEFILE(dlls/dwrite/tests) WINE_CONFIG_MAKEFILE(dlls/dx8vb) diff --git a/dlls/dwmapi/dwmapi_main.c b/dlls/dwmapi/dwmapi_main.c index 6378a091f0..8408a2efed 100644 --- a/dlls/dwmapi/dwmapi_main.c +++ b/dlls/dwmapi/dwmapi_main.c @@ -60,6 +60,9 @@ HRESULT WINAPI DwmIsCompositionEnabled(BOOL *enabled) else TRACE("%p\n", enabled);
+ if (!enabled) + return E_INVALIDARG; + *enabled = FALSE; return S_OK; } diff --git a/dlls/dwmapi/tests/Makefile.in b/dlls/dwmapi/tests/Makefile.in new file mode 100644 index 0000000000..6c6130401d --- /dev/null +++ b/dlls/dwmapi/tests/Makefile.in @@ -0,0 +1,5 @@ +TESTDLL = dwmapi.dll +IMPORTS = dwmapi + +C_SRCS = \ + dwmapi.c diff --git a/dlls/dwmapi/tests/dwmapi.c b/dlls/dwmapi/tests/dwmapi.c new file mode 100644 index 0000000000..1904e283bb --- /dev/null +++ b/dlls/dwmapi/tests/dwmapi.c @@ -0,0 +1,39 @@ +/* + * Copyright 2020 Zhiyi Zhang for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "dwmapi.h" +#include "wine/test.h" + +static void test_DwmIsCompositionEnabled(void) +{ + BOOL enabled; + HRESULT hr; + + hr = DwmIsCompositionEnabled(NULL); + ok(hr == E_INVALIDARG, "Expected %#x, got %#x.\n", E_INVALIDARG, hr); + + enabled = -1; + hr = DwmIsCompositionEnabled(&enabled); + ok(hr == S_OK, "Expected %#x, got %#x.\n", S_OK, hr); + ok(enabled == TRUE || enabled == FALSE, "Got unexpected %#x.\n", enabled); +} + +START_TEST(dwmapi) +{ + test_DwmIsCompositionEnabled(); +}