From 47217b00d4acdeb4c741e50daf848d79ecd014cb Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Thu, 1 Dec 2011 17:11:45 +0000 Subject: [PATCH] Check that UIT_GetWebView() is non-NULL before dereferencing (issue #441). git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@401 5089003a-bbd8-11dd-ad1f-f1f9622dbc98 --- libcef/browser_webview_delegate_gtk.cc | 3 +- libcef/browser_webview_delegate_win.cc | 3 +- libcef/web_drop_target_win.cc | 39 +++++++++++++++++--------- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/libcef/browser_webview_delegate_gtk.cc b/libcef/browser_webview_delegate_gtk.cc index a846386f9..ce33583c7 100644 --- a/libcef/browser_webview_delegate_gtk.cc +++ b/libcef/browser_webview_delegate_gtk.cc @@ -296,7 +296,8 @@ void BrowserWebViewDelegate::startDragging( const WebImage& image, const WebPoint& image_offset) { // TODO(port): Support drag and drop. - browser_->UIT_GetWebView()->dragSourceSystemDragEnded(); + if (browser_->UIT_GetWebView()) + browser_->UIT_GetWebView()->dragSourceSystemDragEnded(); } void BrowserWebViewDelegate::runModal() { diff --git a/libcef/browser_webview_delegate_win.cc b/libcef/browser_webview_delegate_win.cc index e26af7879..2e940aaf8 100644 --- a/libcef/browser_webview_delegate_win.cc +++ b/libcef/browser_webview_delegate_win.cc @@ -534,7 +534,8 @@ void BrowserWebViewDelegate::RevokeDragDrop() { } void BrowserWebViewDelegate::EndDragging() { - browser_->UIT_GetWebView()->dragSourceSystemDragEnded(); + if (browser_->UIT_GetWebView()) + browser_->UIT_GetWebView()->dragSourceSystemDragEnded(); drag_delegate_ = NULL; } diff --git a/libcef/web_drop_target_win.cc b/libcef/web_drop_target_win.cc index 244564a96..615fd3ea4 100644 --- a/libcef/web_drop_target_win.cc +++ b/libcef/web_drop_target_win.cc @@ -95,11 +95,16 @@ DWORD WebDropTarget::OnDragEnter(IDataObject* data_object, POINT client_pt = cursor_position; ScreenToClient(GetHWND(), &client_pt); - WebDragOperation operation = browser_->UIT_GetWebView()->dragTargetDragEnter( - drop_data.ToDragData(), - WebPoint(client_pt.x, client_pt.y), - WebPoint(cursor_position.x, cursor_position.y), - mask); + WebDragOperation operation; + if (browser_->UIT_GetWebView()) { + operation = browser_->UIT_GetWebView()->dragTargetDragEnter( + drop_data.ToDragData(), + WebPoint(client_pt.x, client_pt.y), + WebPoint(cursor_position.x, cursor_position.y), + mask); + } else { + operation = WebDragOperationNone; + } return web_drag_utils_win::WebDragOpToWinDragOp(operation); } @@ -117,10 +122,15 @@ DWORD WebDropTarget::OnDragOver(IDataObject* data_object, POINT client_pt = cursor_position; ScreenToClient(GetHWND(), &client_pt); - WebDragOperation operation = browser_->UIT_GetWebView()->dragTargetDragOver( - WebPoint(client_pt.x, client_pt.y), - WebPoint(cursor_position.x, cursor_position.y), - web_drag_utils_win::WinDragOpMaskToWebDragOpMask(effects)); + WebDragOperation operation; + if (browser_->UIT_GetWebView()) { + browser_->UIT_GetWebView()->dragTargetDragOver( + WebPoint(client_pt.x, client_pt.y), + WebPoint(cursor_position.x, cursor_position.y), + web_drag_utils_win::WinDragOpMaskToWebDragOpMask(effects)); + } else { + operation = WebDragOperationNone; + } return web_drag_utils_win::WebDragOpToWinDragOp(operation); } @@ -133,7 +143,8 @@ void WebDropTarget::OnDragLeave(IDataObject* data_object) { if (canceled_) return; - browser_->UIT_GetWebView()->dragTargetDragLeave(); + if (browser_->UIT_GetWebView()) + browser_->UIT_GetWebView()->dragTargetDragLeave(); } DWORD WebDropTarget::OnDrop(IDataObject* data_object, @@ -148,9 +159,11 @@ DWORD WebDropTarget::OnDrop(IDataObject* data_object, ScreenToClient(GetHWND(), &client_pt); browser_->set_is_dropping(true); - browser_->UIT_GetWebView()->dragTargetDrop( - WebPoint(client_pt.x, client_pt.y), - WebPoint(cursor_position.x, cursor_position.y)); + if (browser_->UIT_GetWebView()) { + browser_->UIT_GetWebView()->dragTargetDrop( + WebPoint(client_pt.x, client_pt.y), + WebPoint(cursor_position.x, cursor_position.y)); + } browser_->set_is_dropping(false); current_wvh_ = NULL;