summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbacker@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-02 14:38:48 +0000
committerbacker@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-02 14:38:48 +0000
commitbc60a3cc21758e54653f7a90e9517f21e5e5ea18 (patch)
treecc92cdd03eb802a836c708ef206b6f3f787880e9
parent47761a52b1eb32b1b941f78f44d335021ace3b2c (diff)
downloadchromium_src-bc60a3cc21758e54653f7a90e9517f21e5e5ea18.zip
chromium_src-bc60a3cc21758e54653f7a90e9517f21e5e5ea18.tar.gz
chromium_src-bc60a3cc21758e54653f7a90e9517f21e5e5ea18.tar.bz2
Don't dereference NULL pointers.
According to render_widget_host.h, view() can return NULL. This patch checks the value of view() before dereferencing it. BUG=crash reports indicate failure at point of dereferencing TEST=none (don't know how to repro) Review URL: http://codereview.chromium.org/6250084 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@73452 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/gpu_process_host.cc34
-rw-r--r--chrome/browser/gpu_process_host_ui_shim.cc13
2 files changed, 28 insertions, 19 deletions
diff --git a/chrome/browser/gpu_process_host.cc b/chrome/browser/gpu_process_host.cc
index a1e8a66..5782c0b 100644
--- a/chrome/browser/gpu_process_host.cc
+++ b/chrome/browser/gpu_process_host.cc
@@ -264,25 +264,31 @@ void CVCBThreadHopping::GetViewWindow(
host = static_cast<RenderWidgetHost*>(
process->GetListenerByID(render_view_id));
}
-#if defined(OS_LINUX)
- gfx::NativeViewId view = NULL;
+
+ RenderWidgetHostView* view = NULL;
if (host)
- view = gfx::IdFromNativeView(host->view()->GetNativeView());
+ view = host->view();
- // Lock the window that we will draw into.
- GtkNativeViewManager* manager = GtkNativeViewManager::GetInstance();
- if (!manager->GetPermanentXIDForId(&window, view)) {
- DLOG(ERROR) << "Can't find XID for view id " << view;
- }
+ if (view) {
+#if defined(OS_LINUX)
+ gfx::NativeViewId view_id = NULL;
+ view_id = gfx::IdFromNativeView(view->GetNativeView());
+
+ // Lock the window that we will draw into.
+ GtkNativeViewManager* manager = GtkNativeViewManager::GetInstance();
+ if (!manager->GetPermanentXIDForId(&window, view_id)) {
+ DLOG(ERROR) << "Can't find XID for view id " << view_id;
+ }
#elif defined(OS_MACOSX)
- // On Mac OS X we currently pass a (fake) PluginWindowHandle for the
- // window that we draw to.
- window = host->view()->AllocateFakePluginWindowHandle(
- /*opaque=*/true, /*root=*/true);
+ // On Mac OS X we currently pass a (fake) PluginWindowHandle for the
+ // window that we draw to.
+ window = view->AllocateFakePluginWindowHandle(
+ /*opaque=*/true, /*root=*/true);
#elif defined(OS_WIN)
- // Create a window that we will overlay.
- window = host->view()->GetCompositorHostWindow();
+ // Create a window that we will overlay.
+ window = view->GetCompositorHostWindow();
#endif
+ }
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, NewRunnableFunction(
&CVCBThreadHopping::DispatchIPCAndQueueReply,
diff --git a/chrome/browser/gpu_process_host_ui_shim.cc b/chrome/browser/gpu_process_host_ui_shim.cc
index ebf7e06..43b5df1 100644
--- a/chrome/browser/gpu_process_host_ui_shim.cc
+++ b/chrome/browser/gpu_process_host_ui_shim.cc
@@ -129,14 +129,17 @@ void GpuProcessHostUIShim::OnDestroyCommandBuffer(
host = static_cast<RenderWidgetHost*>(
process->GetListenerByID(render_view_id));
}
- if (!host)
- return;
+ RenderWidgetHostView* view = NULL;
+ if (host)
+ view = host->view();
+
+ if (view) {
#if defined(OS_MACOSX)
- host->view()->DestroyFakePluginWindowHandle(window);
+ view->DestroyFakePluginWindowHandle(window);
#elif defined(OS_WIN)
- host->view()->ShowCompositorHostWindow(false);
+ view->ShowCompositorHostWindow(false);
#endif
-
+ }
#endif // defined(OS_MACOSX) || defined(OS_WIN)
}