From d0b683b69c926467468b4ca0b93d670317f7a2dc Mon Sep 17 00:00:00 2001 From: "jcivelli@chromium.org" Date: Wed, 19 May 2010 16:07:03 +0000 Subject: A crasher would sometimes happen when opening a selet file dialog (such as when loading an unpacled extension). This is because we would reinterpret cast the user data of the HWND to a WidgetWin, and in that case the Windows dialog has a user-data that we did not set. This CL checks that the HWND is at least a WindowImpl before attempting to retrieve the WidgetWin, ensuring we won't mess with windows we did not create directly. BUG=44312 TEST=Open the extension page. Move the focus by pressing TAB to the "Load unpacked extension..." button. Press ENTER many times quickly so it opens/closes the "Select dir" dialog. It should not crash. Review URL: http://codereview.chromium.org/2124009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47672 0039d316-1c4b-4281-b951-d872f2087c98 --- views/widget/widget_win.cc | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'views/widget') diff --git a/views/widget/widget_win.cc b/views/widget/widget_win.cc index c88e218..2b4c649 100644 --- a/views/widget/widget_win.cc +++ b/views/widget/widget_win.cc @@ -65,6 +65,11 @@ WidgetWin::~WidgetWin() { // static WidgetWin* WidgetWin::GetWidget(HWND hwnd) { + // TODO(jcivelli): http://crbug.com/44499 We need a way to test that hwnd is + // associated with a WidgetWin (it might be a pure + // WindowImpl). + if (!WindowImpl::IsWindowImpl(hwnd)) + return NULL; return reinterpret_cast(win_util::GetWindowUserData(hwnd)); } -- cgit v1.1