Piotr Caban : shell32: Handle TRASH_EnumItems failures correctly.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Feb 2 08:32:23 CST 2015


Module: wine
Branch: master
Commit: d46862b4874519d70a4138285a6b754e3e0c4c20
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=d46862b4874519d70a4138285a6b754e3e0c4c20

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Fri Jan 30 17:03:30 2015 +0100

shell32: Handle TRASH_EnumItems failures correctly.

---

 dlls/shell32/recyclebin.c       | 15 ++++++++++++---
 dlls/shell32/tests/recyclebin.c | 21 +++++++++++----------
 2 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/dlls/shell32/recyclebin.c b/dlls/shell32/recyclebin.c
index d839329..7053998 100644
--- a/dlls/shell32/recyclebin.c
+++ b/dlls/shell32/recyclebin.c
@@ -411,7 +411,7 @@ static HRESULT WINAPI RecycleBin_EnumObjects(IShellFolder2 *iface, HWND hwnd, SH
     IEnumIDListImpl *list;
     LPITEMIDLIST *pidls;
     HRESULT ret = E_OUTOFMEMORY;
-    int pidls_count;
+    int pidls_count = 0;
     int i=0;
 
     TRACE("(%p, %p, %x, %p)\n", This, hwnd, grfFlags, ppenumIDList);
@@ -860,10 +860,14 @@ HRESULT WINAPI SHQueryRecycleBinW(LPCWSTR pszRootPath, LPSHQUERYRBINFO pSHQueryR
     LPITEMIDLIST *apidl;
     INT cidl;
     INT i=0;
+    HRESULT hr;
+
     TRACE("(%s, %p)\n", debugstr_w(pszRootPath), pSHQueryRBInfo);
     FIXME("Ignoring pszRootPath=%s\n",debugstr_w(pszRootPath));
 
-    TRASH_EnumItems(&apidl,&cidl);
+    hr = TRASH_EnumItems(&apidl,&cidl);
+    if (FAILED(hr))
+        return hr;
     pSHQueryRBInfo->i64NumItems = cidl;
     pSHQueryRBInfo->i64Size = 0;
     for (; i<cidl; i++)
@@ -894,9 +898,14 @@ HRESULT WINAPI SHEmptyRecycleBinW(HWND hwnd, LPCWSTR pszRootPath, DWORD dwFlags)
     INT cidl;
     INT i=0;
     HRESULT ret;
+
     TRACE("(%p, %s, 0x%08x)\n", hwnd, debugstr_w(pszRootPath) , dwFlags);
     FIXME("Ignoring pszRootPath=%s\n",debugstr_w(pszRootPath));
-    TRASH_EnumItems(&apidl,&cidl);
+
+    ret = TRASH_EnumItems(&apidl,&cidl);
+    if (FAILED(ret))
+        return ret;
+
     ret = erase_items(hwnd,(const LPCITEMIDLIST*)apidl,cidl,!(dwFlags & SHERB_NOCONFIRMATION));
     for (;i<cidl;i++)
         ILFree(apidl[i]);
diff --git a/dlls/shell32/tests/recyclebin.c b/dlls/shell32/tests/recyclebin.c
index c798492..ba99adf 100644
--- a/dlls/shell32/tests/recyclebin.c
+++ b/dlls/shell32/tests/recyclebin.c
@@ -70,9 +70,12 @@ static void test_query_recyclebin(void)
     ok(GetTempFileNameA(temp_path, "trash", 0, buf), "GetTempFileName failed\n");
     buf[strlen(buf) + 1] = '\0';
     hr = pSHQueryRecycleBinA(buf,&info1);
-    ok(hr == S_OK, "SHQueryRecycleBinA failed with error 0x%x\n", hr);
-    ok(info1.i64Size!=0xdeadbeef,"i64Size not set\n");
-    ok(info1.i64NumItems!=0xdeadbeef,"i64NumItems not set\n");
+    if(hr != S_OK) todo_wine ok(hr == S_OK, "SHQueryRecycleBinA failed with error 0x%x\n", hr);
+    else {
+        ok(hr == S_OK, "SHQueryRecycleBinA failed with error 0x%x\n", hr);
+        ok(info1.i64Size!=0xdeadbeef,"i64Size not set\n");
+        ok(info1.i64NumItems!=0xdeadbeef,"i64NumItems not set\n");
+    }
     /*create and send a file to the recycle bin*/
     file = CreateFileA(buf,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,0,NULL);
     ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n",buf);
@@ -87,13 +90,11 @@ static void test_query_recyclebin(void)
     shfo.lpszProgressTitle = NULL;
     ok(!pSHFileOperationA(&shfo), "Deletion was not successful\n");
     hr = pSHQueryRecycleBinA(buf,&info2);
-    ok(hr == S_OK, "SHQueryRecycleBinW failed with error 0x%x\n", hr);
-    if(info2.i64Size!=info1.i64Size || info2.i64NumItems!=info1.i64NumItems) {
-      ok(info2.i64Size==info1.i64Size+written,"Expected recycle bin to have 0x%s bytes\n",str_from_int64(info1.i64Size+written));
-      ok(info2.i64NumItems==info1.i64NumItems+1,"Expected recycle bin to have 0x%s items\n",str_from_int64(info1.i64NumItems+1));
-    } else todo_wine {
-      ok(info2.i64Size==info1.i64Size+written,"Expected recycle bin to have 0x%s bytes\n",str_from_int64(info1.i64Size+written));
-      ok(info2.i64NumItems==info1.i64NumItems+1,"Expected recycle bin to have 0x%s items\n",str_from_int64(info1.i64NumItems+1));
+    if(hr != S_OK) todo_wine ok(hr == S_OK, "SHQueryRecycleBinA failed with error 0x%x\n", hr);
+    else {
+        ok(hr == S_OK, "SHQueryRecycleBinA failed with error 0x%x\n", hr);
+        ok(info2.i64Size==info1.i64Size+written,"Expected recycle bin to have 0x%s bytes\n",str_from_int64(info1.i64Size+written));
+        ok(info2.i64NumItems==info1.i64NumItems+1,"Expected recycle bin to have 0x%s items\n",str_from_int64(info1.i64NumItems+1));
     }
 }
 




More information about the wine-cvs mailing list