Commit b1dae1bf authored by Stuart Langley's avatar Stuart Langley Committed by Commit Bot

Ensure that we always pass a non-null WTF string to mojo calls.

This fixes a crashing bug, where an empty WebString is passed to
WriteImage for the title parameter. When mojo serializes this it is
converted to a WTF::String that mojo detects is null and sends null
across the wire. On the receive side it is expecting a non null
string so deserialization of the message fails.

This patch sends an empty string instead of a null string, which
matches the pre-mojo state of the code that used to call Utf16() on
the WebString.

Bug: 794512
Change-Id: I3eb8d6c23ca6a9ff435802521366f03f7cb60d43
Reviewed-on: https://chromium-review.googlesource.com/826826Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Commit-Queue: Stuart Langley <slangley@chromium.org>
Cr-Commit-Position: refs/heads/master@{#524155}
parent 29b6c4a7
......@@ -69,6 +69,14 @@ WTF::String URLToImageMarkup(const WebURL& url, const WTF::String& title) {
}
#endif
String EnsureNotNullWTFString(const WebString& string) {
String result = string;
if (result.IsNull()) {
return g_empty_string16_bit;
}
return result;
}
} // namespace
WebClipboardImpl::WebClipboardImpl() {
......@@ -160,7 +168,7 @@ WebString WebClipboardImpl::ReadCustomData(mojom::ClipboardBuffer buffer,
return WebString();
WTF::String data;
clipboard_->ReadCustomData(buffer, type, &data);
clipboard_->ReadCustomData(buffer, EnsureNotNullWTFString(type), &data);
return data;
}
......@@ -192,7 +200,7 @@ void WebClipboardImpl::WriteImage(const WebImage& image,
if (url.IsValid() && !url.IsEmpty()) {
clipboard_->WriteBookmark(mojom::ClipboardBuffer::kStandard,
url.GetString(), title);
url.GetString(), EnsureNotNullWTFString(title));
#if !defined(OS_MACOSX)
// When writing the image, we also write the image markup so that pasting
// into rich text editors, such as Gmail, reveals the image. We also don't
......
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