Nikolay Sivov : shell32/shellview: Don't crash on :: DragLeave called without droptraget.
Alexandre Julliard
julliard at winehq.org
Mon Mar 15 12:19:37 CDT 2010
Module: wine
Branch: master
Commit: 345ab7d591bcc9c5d308a18f00d3f67aa6e887ce
URL: http://source.winehq.org/git/wine.git/?a=commit;h=345ab7d591bcc9c5d308a18f00d3f67aa6e887ce
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Thu Mar 11 17:39:48 2010 +0300
shell32/shellview: Don't crash on ::DragLeave called without droptraget.
---
dlls/shell32/shlview.c | 22 +++++++++++++++-------
dlls/shell32/tests/shlview.c | 8 ++++++++
2 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/dlls/shell32/shlview.c b/dlls/shell32/shlview.c
index cf90982..7809344 100644
--- a/dlls/shell32/shlview.c
+++ b/dlls/shell32/shlview.c
@@ -2407,17 +2407,25 @@ static HRESULT WINAPI ISVDropTarget_DragOver(IDropTarget *iface, DWORD grfKeySta
return drag_notify_subitem(This, grfKeyState, pt, pdwEffect);
}
-static HRESULT WINAPI ISVDropTarget_DragLeave(IDropTarget *iface) {
+static HRESULT WINAPI ISVDropTarget_DragLeave(IDropTarget *iface)
+{
IShellViewImpl *This = impl_from_IDropTarget(iface);
- IDropTarget_DragLeave(This->pCurDropTarget);
+ if (This->pCurDropTarget)
+ {
+ IDropTarget_DragLeave(This->pCurDropTarget);
+ IDropTarget_Release(This->pCurDropTarget);
+ This->pCurDropTarget = NULL;
+ }
+
+ if (This->pCurDataObject)
+ {
+ IDataObject_Release(This->pCurDataObject);
+ This->pCurDataObject = NULL;
+ }
- IDropTarget_Release(This->pCurDropTarget);
- IDataObject_Release(This->pCurDataObject);
- This->pCurDataObject = NULL;
- This->pCurDropTarget = NULL;
This->iDragOverItem = 0;
-
+
return S_OK;
}
diff --git a/dlls/shell32/tests/shlview.c b/dlls/shell32/tests/shlview.c
index ac603c1..31f47c1 100644
--- a/dlls/shell32/tests/shlview.c
+++ b/dlls/shell32/tests/shlview.c
@@ -318,6 +318,7 @@ static void test_IShellView_CreateViewWindow(void)
IShellFolder *desktop;
FOLDERSETTINGS settings;
IShellView *view;
+ IDropTarget *dt;
HWND hwnd_view;
HRESULT hr;
RECT r = {0};
@@ -346,6 +347,13 @@ if (0)
ok(hr == E_UNEXPECTED, "got (0x%08x)\n", hr);
ok(hwnd_view == 0, "got %p\n", hwnd_view);
+ /* ::DragLeave without drag operation */
+ hr = IShellView_QueryInterface(view, &IID_IDropTarget, (void**)&dt);
+ ok(hr == S_OK, "got (0x%08x)\n", hr);
+ hr = IDropTarget_DragLeave(dt);
+ ok(hr == S_OK, "got (0x%08x)\n", hr);
+ IDropTarget_Release(dt);
+
IShellView_Release(view);
IShellFolder_Release(desktop);
}
More information about the wine-cvs
mailing list