Zhiyi Zhang : dwmapi: Check NULL parameter in DwmIsCompositionEnabled().

Alexandre Julliard julliard at winehq.org
Tue Nov 10 13:46:23 CST 2020


Module: wine
Branch: stable
Commit: fb92baa3d1cfd3a6f645b1e37abf8e58bca4a104
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=fb92baa3d1cfd3a6f645b1e37abf8e58bca4a104

Author: Zhiyi Zhang <zzhang at 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 at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit 1ec8bf9b739f1528b742169670eac2350b33a7d4)
Signed-off-by: Michael Stefaniuc <mstefani at 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 8ae79bf336d..f60401a0f7e 100755
--- a/configure
+++ b/configure
@@ -20414,6 +20414,7 @@ wine_fn_config_makefile dlls/dssenh/tests enable_tests
 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 6a28988a542..c8ef570a60d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3223,6 +3223,7 @@ WINE_CONFIG_MAKEFILE(dlls/dssenh/tests)
 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 6378a091f0b..8408a2efed1 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 00000000000..6c6130401d6
--- /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 00000000000..1904e283bba
--- /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();
+}




More information about the wine-cvs mailing list