From d5e7e7827677ffb78b0b9142e2ab5e289cc9de49 Mon Sep 17 00:00:00 2001 From: "piman@chromium.org" Date: Thu, 30 Jul 2009 02:07:27 +0000 Subject: linux: fix plugins crash: 0 is a valid shm handle. Review URL: http://codereview.chromium.org/159487 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22037 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/common/transport_dib.h | 12 ++++++++++++ chrome/renderer/webplugin_delegate_proxy.cc | 6 +++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/chrome/common/transport_dib.h b/chrome/common/transport_dib.h index 495d29f..6d137ff 100644 --- a/chrome/common/transport_dib.h +++ b/chrome/common/transport_dib.h @@ -69,13 +69,25 @@ class TransportDIB { uint32 sequence_num; }; typedef HandleAndSequenceNum Id; + + // Returns a default, invalid handle, that is meant to indicate a missing + // Transport DIB. + static Handle DefaultHandleValue() { return NULL; } #elif defined(OS_MACOSX) typedef base::SharedMemoryHandle Handle; // On Mac, the inode number of the backing file is used as an id. typedef base::SharedMemoryId Id; + + // Returns a default, invalid handle, that is meant to indicate a missing + // Transport DIB. + static Handle DefaultHandleValue() { return Handle(); } #elif defined(OS_LINUX) typedef int Handle; // These two ints are SysV IPC shared memory keys typedef int Id; + + // Returns a default, invalid handle, that is meant to indicate a missing + // Transport DIB. + static Handle DefaultHandleValue() { return -1; } #endif // Create a new TransportDIB diff --git a/chrome/renderer/webplugin_delegate_proxy.cc b/chrome/renderer/webplugin_delegate_proxy.cc index 868be43..3d7cb79 100644 --- a/chrome/renderer/webplugin_delegate_proxy.cc +++ b/chrome/renderer/webplugin_delegate_proxy.cc @@ -426,7 +426,7 @@ void WebPluginDelegateProxy::UpdateGeometry( // so only do so if we've actually recreated the shared memory bitmaps. if (!bitmaps_changed) { msg = new PluginMsg_UpdateGeometry(instance_id_, window_rect, clip_rect, - TransportDIB::Handle(), TransportDIB::Handle()); + TransportDIB::DefaultHandleValue(), TransportDIB::DefaultHandleValue()); } else #endif if (transport_store_.get() && background_store_.get()) { @@ -434,10 +434,10 @@ void WebPluginDelegateProxy::UpdateGeometry( transport_store_->handle(), background_store_->handle()); } else if (transport_store_.get()) { msg = new PluginMsg_UpdateGeometry(instance_id_, window_rect, clip_rect, - transport_store_->handle(), TransportDIB::Handle()); + transport_store_->handle(), TransportDIB::DefaultHandleValue()); } else { msg = new PluginMsg_UpdateGeometry(instance_id_, window_rect, clip_rect, - TransportDIB::Handle(), TransportDIB::Handle()); + TransportDIB::DefaultHandleValue(), TransportDIB::DefaultHandleValue()); } msg->set_unblock(true); -- cgit v1.1