[SHLWAPI_APITEST] Fix heap assertion and test failures (#8217)

- Properly initialize a string in SHPropertyBag test. This prevents a heap assertion failure on Vista+ when freed and connected to a debugger.
- Adjust a value against Windows 8+ instead of Vista as originally assumed in the IsQSForward test.
- Use GetVersion() to check if we are running on NT6+ and test appropriately in the PathIsUNC and PathIsUNCServer tests.
This commit is contained in:
Carl J. Bialorucki 2025-07-05 15:09:23 -06:00 committed by GitHub
parent 375fca5058
commit a993c589ae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 21 additions and 10 deletions

View file

@ -13,7 +13,7 @@
#include <pseh/pseh2.h>
#include <versionhelpers.h>
static BOOL g_bVista = FALSE;
static const BOOL g_bWin8 = IsWindows8OrGreater();
static HRESULT
IsQSForwardMockup(_In_opt_ const GUID *pguidCmdGroup, _In_ ULONG cCmds, _In_ OLECMD *prgCmds)
@ -63,7 +63,7 @@ IsQSForwardMockup(_In_opt_ const GUID *pguidCmdGroup, _In_ ULONG cCmds, _In_ OLE
{
if (!IsEqualGUID(CGID_Explorer, *pguidCmdGroup))
{
if (g_bVista)
if (g_bWin8)
return OLECMDERR_E_UNKNOWNGROUP;
else
return OLECMDERR_E_NOTSUPPORTED;
@ -363,8 +363,6 @@ static VOID TEST_MayExecForwardMockup(VOID)
START_TEST(IsQSForward)
{
g_bVista = IsWindowsVistaOrGreater();
TEST_IsQSForward();
TEST_MayQSForwardMockup();
TEST_MayExecForwardMockup();

View file

@ -40,8 +40,10 @@ START_TEST(isuncpath)
DO_TEST(FALSE, L"path1");
DO_TEST(FALSE, L"c:\\path1");
/* MSDN says FALSE but the test shows TRUE on Windows 2003, but returns FALSE on Windows 7 */
DO_TEST(TRUE, L"\\\\?\\c:\\path1");
if (GetNTVersion() >= _WIN32_WINNT_VISTA)
DO_TEST(FALSE, L"\\\\?\\c:\\path1");
else
DO_TEST(TRUE, L"\\\\?\\c:\\path1");
DO_TEST(TRUE, L"\\\\path1\\");
DO_TEST(FALSE, L"//");
@ -53,6 +55,8 @@ START_TEST(isuncpath)
DO_TEST(FALSE, (wchar_t*)NULL);
DO_TEST(FALSE, L" ");
/* The test shows TRUE on Windows 2003, but returns FALSE on Windows 7 */
DO_TEST(TRUE, L"\\\\?\\");
if (GetNTVersion() >= _WIN32_WINNT_VISTA)
DO_TEST(FALSE, L"\\\\?\\");
else
DO_TEST(TRUE, L"\\\\?\\");
}

View file

@ -39,6 +39,8 @@ START_TEST(isuncpathserver)
DO_TEST(FALSE, L"");
DO_TEST(FALSE, L" ");
/* The test shows TRUE on Windows 2003, but returns FALSE on Windows 7 */
DO_TEST(TRUE, L"\\\\?");
if (GetNTVersion() >= _WIN32_WINNT_VISTA)
DO_TEST(FALSE, L"\\\\?");
else
DO_TEST(TRUE, L"\\\\?");
}

View file

@ -95,6 +95,13 @@ public:
if (lstrcmpiW(pszPropName, L"RECTL2.top") == 0)
return E_FAIL;
if (lstrcmpiW(pszPropName, L"Str1") == 0)
{
V_VT(pvari) = VT_BSTR;
V_BSTR(pvari) = SysAllocString(L"TestString");
return S_OK;
}
if (lstrcmpiW(pszPropName, L"GUID1") == 0)
{
V_VT(pvari) = (VT_UI1 | VT_ARRAY);