shlwapi: Fix AssocQueryStringW parameter checking.

This commit is contained in:
Lei Zhang 2008-10-10 22:21:25 -07:00 committed by Alexandre Julliard
parent 0c568c2ae8
commit db08d6e807
2 changed files with 24 additions and 26 deletions

View File

@ -244,7 +244,7 @@ HRESULT WINAPI AssocQueryStringW(ASSOCF cfFlags, ASSOCSTR str, LPCWSTR pszAssoc,
debugstr_w(pszExtra), pszOut, pcchOut);
if (!pcchOut)
return E_INVALIDARG;
return E_UNEXPECTED;
lpAssoc = IQueryAssociations_Constructor();
@ -290,7 +290,7 @@ HRESULT WINAPI AssocQueryStringA(ASSOCF cfFlags, ASSOCSTR str, LPCSTR pszAssoc,
debugstr_a(pszExtra), pszOut, pcchOut);
if (!pcchOut)
hRet = E_INVALIDARG;
hRet = E_UNEXPECTED;
else if (SHLWAPI_ParamAToW(pszAssoc, szAssocW, MAX_PATH, &lpszAssocW) &&
SHLWAPI_ParamAToW(pszExtra, szExtraW, MAX_PATH, &lpszExtraW))
{
@ -520,7 +520,7 @@ static HRESULT WINAPI IQueryAssociations_fnInit(
{
static const WCHAR szProgID[] = {'P','r','o','g','I','D',0};
IQueryAssociationsImpl *This = (IQueryAssociationsImpl *)iface;
HRESULT hr;
LONG ret;
TRACE("(%p)->(%d,%s,%p,%p)\n", iface,
cfFlags,
@ -533,23 +533,21 @@ static HRESULT WINAPI IQueryAssociations_fnInit(
FIXME("unsupported flags: %x\n", cfFlags);
if (pszAssoc != NULL)
{
hr = RegOpenKeyExW(HKEY_CLASSES_ROOT,
pszAssoc,
0,
KEY_READ,
&This->hkeySource);
if (FAILED(hr))
return HRESULT_FROM_WIN32(ERROR_NO_ASSOCIATION);
ret = RegOpenKeyExW(HKEY_CLASSES_ROOT,
pszAssoc,
0,
KEY_READ,
&This->hkeySource);
if (ret != ERROR_SUCCESS)
return E_FAIL;
/* if this is not a prog id */
if ((*pszAssoc == '.') || (*pszAssoc == '{'))
{
hr = RegOpenKeyExW(This->hkeySource,
szProgID,
0,
KEY_READ,
&This->hkeyProgID);
if (FAILED(hr))
FIXME("Don't know what to return\n");
RegOpenKeyExW(This->hkeySource,
szProgID,
0,
KEY_READ,
&This->hkeyProgID);
}
else
This->hkeyProgID = This->hkeySource;
@ -561,7 +559,7 @@ static HRESULT WINAPI IQueryAssociations_fnInit(
return S_OK;
}
else
return E_FAIL;
return E_INVALIDARG;
}
/**************************************************************************

View File

@ -38,31 +38,31 @@ static void test_getstring_bad(void)
DWORD len;
hr = AssocQueryStringW(0, ASSOCSTR_EXECUTABLE, NULL, open, NULL, &len);
todo_wine expect_hr(E_INVALIDARG, hr);
expect_hr(E_INVALIDARG, hr);
hr = AssocQueryStringW(0, ASSOCSTR_EXECUTABLE, badBad, open, NULL, &len);
todo_wine expect_hr(E_FAIL, hr);
expect_hr(E_FAIL, hr);
hr = AssocQueryStringW(0, ASSOCSTR_EXECUTABLE, dotBad, open, NULL, &len);
todo_wine expect_hr(E_FAIL, hr);
expect_hr(E_FAIL, hr);
hr = AssocQueryStringW(0, ASSOCSTR_EXECUTABLE, dotHtml, invalid, NULL,
&len);
todo_wine expect_hr(0x80070002, hr); /* NOT FOUND */
hr = AssocQueryStringW(0, ASSOCSTR_EXECUTABLE, dotHtml, open, NULL, NULL);
todo_wine expect_hr(E_UNEXPECTED, hr);
expect_hr(E_UNEXPECTED, hr);
hr = AssocQueryStringW(0, ASSOCSTR_FRIENDLYAPPNAME, NULL, open, NULL, &len);
todo_wine expect_hr(E_INVALIDARG, hr);
expect_hr(E_INVALIDARG, hr);
hr = AssocQueryStringW(0, ASSOCSTR_FRIENDLYAPPNAME, badBad, open, NULL,
&len);
todo_wine expect_hr(E_FAIL, hr);
expect_hr(E_FAIL, hr);
hr = AssocQueryStringW(0, ASSOCSTR_FRIENDLYAPPNAME, dotBad, open, NULL,
&len);
todo_wine expect_hr(E_FAIL, hr);
expect_hr(E_FAIL, hr);
hr = AssocQueryStringW(0, ASSOCSTR_FRIENDLYAPPNAME, dotHtml, invalid, NULL,
&len);
todo_wine expect_hr(0x80070002, hr); /* NOT FOUND */
hr = AssocQueryStringW(0, ASSOCSTR_FRIENDLYAPPNAME, dotHtml, open, NULL,
NULL);
todo_wine expect_hr(E_UNEXPECTED, hr);
expect_hr(E_UNEXPECTED, hr);
}
static void test_getstring_basic(void)