[PATCH] dwmapi: Check NULL parameter in DwmIsCompositionEnabled().

Zhiyi Zhang zzhang at codeweavers.com
Fri Aug 7 11:02:25 CDT 2020


Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49664
Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
---
Supersede 190398

 configure.ac                  |  1 +
 dlls/dwmapi/dwmapi_main.c     |  3 +++
 dlls/dwmapi/tests/Makefile.in |  5 +++++
 dlls/dwmapi/tests/dwmapi.c    | 39 +++++++++++++++++++++++++++++++++++
 4 files changed, 48 insertions(+)
 create mode 100644 dlls/dwmapi/tests/Makefile.in
 create mode 100644 dlls/dwmapi/tests/dwmapi.c

diff --git a/configure.ac b/configure.ac
index 4ff0f9c81f7..a2a808d5ea9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3273,6 +3273,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 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..5893c5e60a5
--- /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();
+}
-- 
2.25.1



More information about the wine-devel mailing list