From b6e4beca3a071606c537af2d55eba21d99769cb0 Mon Sep 17 00:00:00 2001 From: "joshia@google.com" Date: Wed, 12 Nov 2008 01:17:15 +0000 Subject: Prevent crash due to DIB allocation failure Change the way we capture tab thumbnail images so that the capturing code can deal with failure. BUG=3795 Review URL: http://codereview.chromium.org/9717 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5244 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/renderer/webplugin_delegate_proxy.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'chrome/renderer/webplugin_delegate_proxy.cc') diff --git a/chrome/renderer/webplugin_delegate_proxy.cc b/chrome/renderer/webplugin_delegate_proxy.cc index 67dcce2..efceffb 100644 --- a/chrome/renderer/webplugin_delegate_proxy.cc +++ b/chrome/renderer/webplugin_delegate_proxy.cc @@ -400,12 +400,18 @@ bool WebPluginDelegateProxy::CreateBitmap( scoped_ptr* memory, scoped_ptr* canvas) { size_t size = GetPaintBufSize(plugin_rect_); - memory->reset(new SharedMemory()); - if (!(*memory)->Create(L"", false, true, size)) + scoped_ptr new_shared_memory(new SharedMemory()); + if (!new_shared_memory->Create(L"", false, true, size)) return false; - canvas->reset(new gfx::PlatformCanvasWin( - plugin_rect_.width(), plugin_rect_.height(), true, (*memory)->handle())); + scoped_ptr new_canvas(new gfx::PlatformCanvasWin); + if (!new_canvas->initialize(plugin_rect_.width(), plugin_rect_.height(), + true, new_shared_memory->handle())) { + return false; + } + + memory->swap(new_shared_memory); + canvas->swap(new_canvas); return true; } -- cgit v1.1