From 5f2dd2ef6c39cf96abdbd1d6f57d15d4662779c5 Mon Sep 17 00:00:00 2001 From: Vladimir Vainer Date: Thu, 29 Jun 2017 16:11:57 +0300 Subject: [PATCH] Fix #8017: Crash copying croped image to clipboard --- atom/common/api/atom_api_clipboard.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/atom/common/api/atom_api_clipboard.cc b/atom/common/api/atom_api_clipboard.cc index 430d8629379a..f88df67cf0b5 100644 --- a/atom/common/api/atom_api_clipboard.cc +++ b/atom/common/api/atom_api_clipboard.cc @@ -7,6 +7,7 @@ #include "atom/common/native_mate_converters/image_converter.h" #include "atom/common/native_mate_converters/string16_converter.h" #include "base/strings/utf_string_conversions.h" +#include "third_party/skia/include/core/SkBitmap.h" #include "ui/base/clipboard/scoped_clipboard_writer.h" #include "atom/common/node_includes.h" @@ -166,7 +167,12 @@ gfx::Image Clipboard::ReadImage(mate::Arguments* args) { void Clipboard::WriteImage(const gfx::Image& image, mate::Arguments* args) { ui::ScopedClipboardWriter writer(GetClipboardType(args)); - writer.WriteImage(image.AsBitmap()); + SkBitmap bmp; + if (image.AsBitmap().deepCopyTo(&bmp)) { + writer.WriteImage(bmp); + } else { + writer.WriteImage(image.AsBitmap()); + } } #if !defined(OS_MACOSX)