From a850cafe6d0698676bbc8b75ac7f986e6bf7475d Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Fri, 20 Jun 2008 20:35:53 +1000 Subject: [PATCH] shell32: Stop crash when an error occurs. --- dlls/shell32/tests/shlfolder.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/dlls/shell32/tests/shlfolder.c b/dlls/shell32/tests/shlfolder.c index 950f1d7a8bc..9bb7208d626 100644 --- a/dlls/shell32/tests/shlfolder.c +++ b/dlls/shell32/tests/shlfolder.c @@ -450,21 +450,25 @@ static void test_GetDisplayName(void) /* The pidl returned through the last parameter of SetNameOf is a simple one. */ hr = IShellFolder_SetNameOf(psfPersonal, NULL, pidlLast, wszDirName, SHGDN_NORMAL, &pidlNew); ok (SUCCEEDED(hr), "SetNameOf failed! hr = %08x\n", hr); - ok (((LPITEMIDLIST)((LPBYTE)pidlNew+pidlNew->mkid.cb))->mkid.cb == 0, - "pidl returned from SetNameOf should be simple!\n"); - - /* Passing an absolute path to SetNameOf fails. The HRESULT code indicates that SetNameOf - * is implemented on top of SHFileOperation in WinXP. */ - hr = IShellFolder_SetNameOf(psfPersonal, NULL, pidlNew, wszAbsoluteFilename, - SHGDN_FORPARSING, NULL); - ok (hr == HRESULT_FROM_WIN32(ERROR_CANCELLED), "SetNameOf succeeded! hr = %08x\n", hr); - - /* Rename the file back to its original name. SetNameOf ignores the fact, that the - * SHGDN flags specify an absolute path. */ - hr = IShellFolder_SetNameOf(psfPersonal, NULL, pidlNew, wszFileName, SHGDN_FORPARSING, NULL); - ok (SUCCEEDED(hr), "SetNameOf failed! hr = %08x\n", hr); + if(hr == S_OK) + { + ok (((LPITEMIDLIST)((LPBYTE)pidlNew+pidlNew->mkid.cb))->mkid.cb == 0, + "pidl returned from SetNameOf should be simple!\n"); + + /* Passing an absolute path to SetNameOf fails. The HRESULT code indicates that SetNameOf + * is implemented on top of SHFileOperation in WinXP. */ + hr = IShellFolder_SetNameOf(psfPersonal, NULL, pidlNew, wszAbsoluteFilename, + SHGDN_FORPARSING, NULL); + ok (hr == HRESULT_FROM_WIN32(ERROR_CANCELLED), "SetNameOf succeeded! hr = %08x\n", hr); + + /* Rename the file back to its original name. SetNameOf ignores the fact, that the + * SHGDN flags specify an absolute path. */ + hr = IShellFolder_SetNameOf(psfPersonal, NULL, pidlNew, wszFileName, SHGDN_FORPARSING, NULL); + ok (SUCCEEDED(hr), "SetNameOf failed! hr = %08x\n", hr); + + pILFree(pidlNew); + } - pILFree(pidlNew); IShellFolder_Release(psfPersonal); } -- 2.11.4.GIT