summaryrefslogtreecommitdiff
path: root/chromium/content/browser/renderer_host/clipboard_message_filter.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/content/browser/renderer_host/clipboard_message_filter.cc')
-rw-r--r--chromium/content/browser/renderer_host/clipboard_message_filter.cc20
1 files changed, 11 insertions, 9 deletions
diff --git a/chromium/content/browser/renderer_host/clipboard_message_filter.cc b/chromium/content/browser/renderer_host/clipboard_message_filter.cc
index 2ad35468244..0e2426bf224 100644
--- a/chromium/content/browser/renderer_host/clipboard_message_filter.cc
+++ b/chromium/content/browser/renderer_host/clipboard_message_filter.cc
@@ -115,23 +115,24 @@ void ClipboardMessageFilter::OnWriteObjectsSync(
void ClipboardMessageFilter::OnWriteObjectsAsync(
const ui::Clipboard::ObjectMap& objects) {
+ // This async message doesn't support shared-memory based bitmaps; they must
+ // be removed otherwise we might dereference a rubbish pointer.
+ scoped_ptr<ui::Clipboard::ObjectMap> sanitized_objects(
+ new ui::Clipboard::ObjectMap(objects));
+ sanitized_objects->erase(ui::Clipboard::CBF_SMBITMAP);
+
#if defined(OS_WIN)
// We cannot write directly from the IO thread, and cannot service the IPC
// on the UI thread. We'll copy the relevant data and post a task to preform
// the write on the UI thread.
- ui::Clipboard::ObjectMap* long_living_objects =
- new ui::Clipboard::ObjectMap(objects);
-
- // This async message doesn't support shared-memory based bitmaps; they must
- // be removed otherwise we might dereference a rubbish pointer.
- long_living_objects->erase(ui::Clipboard::CBF_SMBITMAP);
-
BrowserThread::PostTask(
BrowserThread::UI,
FROM_HERE,
- base::Bind(&WriteObjectsOnUIThread, base::Owned(long_living_objects)));
+ base::Bind(
+ &WriteObjectsOnUIThread, base::Owned(sanitized_objects.release())));
#else
- GetClipboard()->WriteObjects(ui::Clipboard::BUFFER_STANDARD, objects);
+ GetClipboard()->WriteObjects(
+ ui::Clipboard::BUFFER_STANDARD, *sanitized_objects.get());
#endif
}
@@ -198,6 +199,7 @@ void ClipboardMessageFilter::OnReadImageReply(
const SkBitmap& bitmap, IPC::Message* reply_msg) {
base::SharedMemoryHandle image_handle = base::SharedMemory::NULLHandle();
uint32 image_size = 0;
+ std::string reply_data;
if (!bitmap.isNull()) {
std::vector<unsigned char> png_data;
SkAutoLockPixels lock(bitmap);