dmloader: Initialize a stack variable to avoid erratic test behavior.

Michael Stefaniuc mstefani at winehq.org
Tue Jul 18 19:24:03 CDT 2017


Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
The code is still wrong but at least the test results make sense now.

As DMUSIC_GetLoaderSettings() is not finding the
GUID_DirectMusicAllTypes class and the return value of that helper is
never checked current_path[] is used unitialized. Which on most systems
happened to be the "correct" stack location prefilled by the
GetTempPathW() in the test. Staging and Alistair box where getting test
failures due to this.


 dlls/dmloader/loader.c       | 2 +-
 dlls/dmloader/tests/loader.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/dlls/dmloader/loader.c b/dlls/dmloader/loader.c
index 41418b8..5825665 100644
--- a/dlls/dmloader/loader.c
+++ b/dlls/dmloader/loader.c
@@ -517,7 +517,7 @@ static HRESULT WINAPI IDirectMusicLoaderImpl_SetSearchDirectory(IDirectMusicLoad
         REFGUID class, WCHAR *path, BOOL clear)
 {
     IDirectMusicLoaderImpl *This = impl_from_IDirectMusicLoader8(iface);
-    WCHAR current_path[MAX_PATH];
+    WCHAR current_path[MAX_PATH] = {0};
     DWORD attr;
 
     TRACE("(%p, %s, %s, %d)\n", This, debugstr_dmguid(class), debugstr_w(path), clear);
diff --git a/dlls/dmloader/tests/loader.c b/dlls/dmloader/tests/loader.c
index 6b2ee3a..1735994 100644
--- a/dlls/dmloader/tests/loader.c
+++ b/dlls/dmloader/tests/loader.c
@@ -66,11 +66,11 @@ static void test_directory(void)
     /* Two consecutive SetSearchDirectory with the same path */
     GetTempPathW(ARRAY_SIZE(path), path);
     hr = IDirectMusicLoader_SetSearchDirectory(loader, &GUID_DirectMusicAllTypes, path, 0);
-    todo_wine ok(hr == S_OK, "SetSearchDirectory failed with %#x\n", hr);
+    ok(hr == S_OK, "SetSearchDirectory failed with %#x\n", hr);
     hr = IDirectMusicLoader_SetSearchDirectory(loader, &GUID_DirectMusicAllTypes, path, 0);
-    ok(hr == S_FALSE, "Second SetSearchDirectory failed with %#x\n", hr);
+    todo_wine ok(hr == S_FALSE, "Second SetSearchDirectory failed with %#x\n", hr);
     hr = IDirectMusicLoader_SetSearchDirectory(loader, &CLSID_DirectSoundWave, path, 0);
-    ok(hr == S_OK, "SetSearchDirectory failed with %#x\n", hr);
+    todo_wine ok(hr == S_OK, "SetSearchDirectory failed with %#x\n", hr);
     hr = IDirectMusicLoader_SetSearchDirectory(loader, &CLSID_DirectSoundWave, path, 0);
     ok(hr == S_FALSE, "Second SetSearchDirectory failed with %#x\n", hr);
 
-- 
2.9.4




More information about the wine-patches mailing list