Commit 5754c666 authored by nohe@chromium.org's avatar nohe@chromium.org Committed by Commit Bot

Prevent accessing null clipboard data.

This change prevents the clipboard data from being accessed if the
clipboard data happens to be null. This is to prevent crashes from
occurring that happened when the nonbacked clipboard held a nullptr for
the data field and we tried to access it.

BUG=1147262

Change-Id: Ic778a18ed592e3d7ad8de1ea2fd949c6b31767db
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2544077Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Commit-Queue: Alexander Nohe <nohe@chromium.org>
Cr-Commit-Position: refs/heads/master@{#828522}
parent f140d1fd
......@@ -69,7 +69,9 @@ void CopyImageToClipboard(bool maintain_clipboard,
std::string html = base::StrCat(
{kImageClipboardFormatPrefix, encoded, kImageClipboardFormatSuffix});
if (!maintain_clipboard) {
if (!maintain_clipboard ||
!ui::ClipboardNonBacked::GetForCurrentThread()->GetClipboardData(
nullptr)) {
ui::ScopedClipboardWriter clipboard_writer(ui::ClipboardBuffer::kCopyPaste);
clipboard_writer.WriteHTML(base::UTF8ToUTF16(html), std::string());
clipboard_writer.WriteImage(decoded_image);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment