Signed-off-by: Alex Henrie <alexhenrie24(a)gmail.com>
---
Discovered while debugging ShareX.
---
dlls/comdlg32/itemdlg.c | 6 +++---
dlls/comdlg32/tests/itemdlg.c | 2 ++
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/dlls/comdlg32/itemdlg.c b/dlls/comdlg32/itemdlg.c
index 1ae20ca782..f17c2f926d 100644
--- a/dlls/comdlg32/itemdlg.c
+++ b/dlls/comdlg32/itemdlg.c
@@ -2402,12 +2402,12 @@ static HRESULT WINAPI IFileDialog2_fnSetFileTypes(IFileDialog2 *iface, UINT cFil
UINT i;
TRACE("%p (%d, %p)\n", This, cFileTypes, rgFilterSpec);
- if(This->filterspecs)
- return E_UNEXPECTED;
-
if(!rgFilterSpec)
return E_INVALIDARG;
+ if(This->filterspecs)
+ return E_UNEXPECTED;
+
if(!cFileTypes)
return S_OK;
diff --git a/dlls/comdlg32/tests/itemdlg.c b/dlls/comdlg32/tests/itemdlg.c
index 6ee0d5fc3d..c38457a0a1 100644
--- a/dlls/comdlg32/tests/itemdlg.c
+++ b/dlls/comdlg32/tests/itemdlg.c
@@ -675,6 +675,8 @@ static void test_basics(void)
ok(hr == S_OK, "got 0x%08x.\n", hr);
hr = IFileOpenDialog_SetFileTypes(pfod, 0, filterspec);
ok(hr == E_UNEXPECTED, "got 0x%08x.\n", hr);
+ hr = IFileOpenDialog_SetFileTypes(pfod, 0, NULL);
+ ok(hr == E_INVALIDARG, "got 0x%08x.\n", hr);
hr = IFileOpenDialog_SetFileTypeIndex(pfod, 0);
ok(hr == S_OK, "got 0x%08x.\n", hr);
hr = IFileOpenDialog_GetFileTypeIndex(pfod, &filetype);
--
2.28.0