From 5e39af2683978d97781b850f4259b5ba3d2ab2b4 Mon Sep 17 00:00:00 2001 From: David Adam Date: Wed, 6 Jan 2010 04:49:39 +0100 Subject: [PATCH] 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(+) create mode 100644 dlls/dmloader/tests/Makefile.in create mode 100644 dlls/dmloader/tests/loader.c diff --git a/configure b/configure index 46800516d73..b81612d3fb1 100755 --- a/configure +++ b/configure @@ -14504,6 +14504,14 @@ ALL_MAKEFILE_DEPENDS="$ALL_MAKEFILE_DEPENDS 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 \\ @@ -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 417e2456922..6cae9bad89f 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 393b6b9fa27..0e9748d9e58 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 00000000000..48a08f414c1 --- /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 + +@MAKE_TEST_RULES@ + +@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 00000000000..dc1ff7a1b55 --- /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 + +#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(); +}