comdlg32/itemdlg: Fix setting NULL file name (Coverity).
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
92e9f4401d
commit
384ece4d7e
|
@ -384,14 +384,12 @@ static UINT get_file_name(FileDialogImpl *This, LPWSTR *str)
|
||||||
|
|
||||||
static BOOL set_file_name(FileDialogImpl *This, LPCWSTR str)
|
static BOOL set_file_name(FileDialogImpl *This, LPCWSTR str)
|
||||||
{
|
{
|
||||||
HWND hwnd_edit = GetDlgItem(This->dlg_hwnd, IDC_FILENAME);
|
|
||||||
|
|
||||||
if(This->set_filename)
|
if(This->set_filename)
|
||||||
LocalFree(This->set_filename);
|
LocalFree(This->set_filename);
|
||||||
|
|
||||||
This->set_filename = StrDupW(str);
|
This->set_filename = str ? StrDupW(str) : NULL;
|
||||||
|
|
||||||
return SendMessageW(hwnd_edit, WM_SETTEXT, 0, (LPARAM)str);
|
return SetDlgItemTextW(This->dlg_hwnd, IDC_FILENAME, This->set_filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fill_filename_from_selection(FileDialogImpl *This)
|
static void fill_filename_from_selection(FileDialogImpl *This)
|
||||||
|
@ -2608,10 +2606,8 @@ static HRESULT WINAPI IFileDialog2_fnGetFileName(IFileDialog2 *iface, LPWSTR *ps
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
|
|
||||||
*pszName = NULL;
|
*pszName = NULL;
|
||||||
if(get_file_name(This, pszName))
|
get_file_name(This, pszName);
|
||||||
return S_OK;
|
return *pszName ? S_OK : E_FAIL;
|
||||||
else
|
|
||||||
return E_FAIL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI IFileDialog2_fnSetTitle(IFileDialog2 *iface, LPCWSTR pszTitle)
|
static HRESULT WINAPI IFileDialog2_fnSetTitle(IFileDialog2 *iface, LPCWSTR pszTitle)
|
||||||
|
|
|
@ -797,6 +797,21 @@ static void test_basics(void)
|
||||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||||
hr = IFileOpenDialog_SetFileName(pfod, null);
|
hr = IFileOpenDialog_SetFileName(pfod, null);
|
||||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||||
|
|
||||||
|
filename = NULL;
|
||||||
|
hr = IFileOpenDialog_GetFileName(pfod, &filename);
|
||||||
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
||||||
|
ok(!lstrcmpW(filename, null), "Strings do not match.\n");
|
||||||
|
CoTaskMemFree(filename);
|
||||||
|
|
||||||
|
hr = IFileOpenDialog_SetFileName(pfod, NULL);
|
||||||
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||||
|
|
||||||
|
filename = (void*)0xdeadbeef;
|
||||||
|
hr = IFileOpenDialog_GetFileName(pfod, &filename);
|
||||||
|
ok(hr == E_FAIL, "Got 0x%08x\n", hr);
|
||||||
|
ok(filename == NULL, "got %p.\n", filename);
|
||||||
|
|
||||||
hr = IFileOpenDialog_SetFileName(pfod, txt);
|
hr = IFileOpenDialog_SetFileName(pfod, txt);
|
||||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||||
hr = IFileOpenDialog_GetFileName(pfod, &filename);
|
hr = IFileOpenDialog_GetFileName(pfod, &filename);
|
||||||
|
|
Loading…
Reference in New Issue