David Adam : dmloader: Fix a possible null dereference.
Alexandre Julliard
julliard at winehq.org
Wed Jan 6 13:00:56 CST 2010
Module: wine
Branch: master
Commit: 5e39af2683978d97781b850f4259b5ba3d2ab2b4
URL: http://source.winehq.org/git/wine.git/?a=commit;h=5e39af2683978d97781b850f4259b5ba3d2ab2b4
Author: David Adam <david.adam.cnrs at gmail.com>
Date: Wed Jan 6 04:49:39 2010 +0100
dmloader: Fix a possible null dereference.
---
configure | 9 ++++++
configure.ac | 1 +
dlls/dmloader/loader.c | 2 +
dlls/dmloader/tests/Makefile.in | 13 +++++++++
dlls/dmloader/tests/loader.c | 57 +++++++++++++++++++++++++++++++++++++++
5 files changed, 82 insertions(+), 0 deletions(-)
diff --git a/configure b/configure
index 4680051..b81612d 100755
--- a/configure
+++ b/configure
@@ -14505,6 +14505,14 @@ dlls/dmloader/Makefile: dlls/dmloader/Makefile.in dlls/Makedll.rules"
ac_config_files="$ac_config_files dlls/dmloader/Makefile"
ALL_MAKEFILES="$ALL_MAKEFILES \\
+ dlls/dmloader/tests/Makefile"
+test "x$enable_tests" != xno && ALL_TEST_DIRS="$ALL_TEST_DIRS \\
+ dmloader/tests"
+ALL_MAKEFILE_DEPENDS="$ALL_MAKEFILE_DEPENDS
+dlls/dmloader/tests/Makefile: dlls/dmloader/tests/Makefile.in dlls/Maketest.rules"
+ac_config_files="$ac_config_files dlls/dmloader/tests/Makefile"
+
+ALL_MAKEFILES="$ALL_MAKEFILES \\
dlls/dmscript/Makefile"
test "x$enable_dmscript" != xno && ALL_DLL_DIRS="$ALL_DLL_DIRS \\
dmscript"
@@ -18839,6 +18847,7 @@ do
"dlls/dmcompos/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/dmcompos/Makefile" ;;
"dlls/dmime/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/dmime/Makefile" ;;
"dlls/dmloader/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/dmloader/Makefile" ;;
+ "dlls/dmloader/tests/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/dmloader/tests/Makefile" ;;
"dlls/dmscript/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/dmscript/Makefile" ;;
"dlls/dmstyle/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/dmstyle/Makefile" ;;
"dlls/dmsynth/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/dmsynth/Makefile" ;;
diff --git a/configure.ac b/configure.ac
index 417e245..6cae9ba 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2224,6 +2224,7 @@ WINE_CONFIG_MAKEFILE([dlls/dmband/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL
WINE_CONFIG_MAKEFILE([dlls/dmcompos/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DIRS])
WINE_CONFIG_MAKEFILE([dlls/dmime/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DIRS])
WINE_CONFIG_MAKEFILE([dlls/dmloader/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DIRS])
+WINE_CONFIG_MAKEFILE([dlls/dmloader/tests/Makefile],[dlls/Maketest.rules],[dlls],[ALL_TEST_DIRS],[enable_tests])
WINE_CONFIG_MAKEFILE([dlls/dmscript/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DIRS])
WINE_CONFIG_MAKEFILE([dlls/dmstyle/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DIRS])
WINE_CONFIG_MAKEFILE([dlls/dmsynth/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DIRS])
diff --git a/dlls/dmloader/loader.c b/dlls/dmloader/loader.c
index 393b6b9..0e9748d 100644
--- a/dlls/dmloader/loader.c
+++ b/dlls/dmloader/loader.c
@@ -644,6 +644,8 @@ static HRESULT WINAPI IDirectMusicLoaderImpl_IDirectMusicLoader_ReleaseObject (L
ICOM_THIS_MULTI(IDirectMusicLoaderImpl, LoaderVtbl, iface);
TRACE("(%p, %p)\n", This, pObject);
+ if(!pObject) return E_POINTER;
+
/* get descriptor */
DM_STRUCT_INIT(&Desc);
IDirectMusicObject_GetDescriptor (pObject, &Desc);
diff --git a/dlls/dmloader/tests/Makefile.in b/dlls/dmloader/tests/Makefile.in
new file mode 100644
index 0000000..48a08f4
--- /dev/null
+++ b/dlls/dmloader/tests/Makefile.in
@@ -0,0 +1,13 @@
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../../..
+SRCDIR = @srcdir@
+VPATH = @srcdir@
+TESTDLL = dmloader.dll
+IMPORTS = ole32 kernel32
+
+CTESTS = \
+ loader.c
+
+ at MAKE_TEST_RULES@
+
+ at DEPENDENCIES@ # everything below this line is overwritten by make depend
diff --git a/dlls/dmloader/tests/loader.c b/dlls/dmloader/tests/loader.c
new file mode 100644
index 0000000..dc1ff7a
--- /dev/null
+++ b/dlls/dmloader/tests/loader.c
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2010 David Adam
+ *
+ * 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 <assert.h>
+
+#define COBJMACROS
+
+#include "initguid.h"
+#include "dmusici.h"
+#include "wine/test.h"
+
+static void test_release_object(void)
+{
+ HRESULT hr;
+ IDirectMusicLoader8* loader = NULL;
+
+ hr = CoInitialize(NULL);
+ if ( FAILED(hr) )
+ {
+ skip("CoInitialize failed.\n");
+ return;
+ }
+
+ hr = CoCreateInstance(&CLSID_DirectMusicLoader, NULL, CLSCTX_INPROC, &IID_IDirectMusicLoader8, (void**)&loader);
+ if ( FAILED(hr) )
+ {
+ skip("CoCreateInstance failed.\n");
+ CoUninitialize();
+ return;
+ }
+
+ hr = IDirectMusicLoader_ReleaseObject(loader, NULL);
+ ok(hr == E_POINTER, "Expected E_POINTER, received %#x\n", hr);
+
+ IDirectMusicLoader_Release(loader);
+ CoUninitialize();
+}
+
+START_TEST(loader)
+{
+ test_release_object();
+}
More information about the wine-cvs
mailing list