diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-17 18:10:26 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-17 18:10:26 +0000 |
commit | 021052dbd3619f6ea8a248dab8f7bea35521048f (patch) | |
tree | f0d6b9c7b37342b8471ccd7433aaefd3f5a1b8f8 /app/clipboard/clipboard_linux.cc | |
parent | 69f1e8f3b85a7f81b3beb64e4b060ebf25db7adb (diff) | |
download | chromium_src-021052dbd3619f6ea8a248dab8f7bea35521048f.zip chromium_src-021052dbd3619f6ea8a248dab8f7bea35521048f.tar.gz chromium_src-021052dbd3619f6ea8a248dab8f7bea35521048f.tar.bz2 |
Linux: Null terminate text/html data we send to the clipboard. Change WriteHyperlink to take string16 anchor text.
BUG=42624
TEST=none
Review URL: http://codereview.chromium.org/2036013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47432 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app/clipboard/clipboard_linux.cc')
-rw-r--r-- | app/clipboard/clipboard_linux.cc | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/app/clipboard/clipboard_linux.cc b/app/clipboard/clipboard_linux.cc index d03d356..71a429f 100644 --- a/app/clipboard/clipboard_linux.cc +++ b/app/clipboard/clipboard_linux.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -153,8 +153,9 @@ void Clipboard::SetGtkClipboard() { } void Clipboard::WriteText(const char* text_data, size_t text_len) { - char* data = new char[text_len]; + char* data = new char[text_len + 1]; memcpy(data, text_data, text_len); + data[text_len] = '\0'; InsertMapping(kMimeText, data, text_len); InsertMapping("TEXT", data, text_len); @@ -171,11 +172,12 @@ void Clipboard::WriteHTML(const char* markup_data, static const char* html_prefix = "<meta http-equiv=\"content-type\" " "content=\"text/html; charset=utf-8\">"; size_t html_prefix_len = strlen(html_prefix); - size_t total_len = html_prefix_len + markup_len; + size_t total_len = html_prefix_len + markup_len + 1; char* data = new char[total_len]; snprintf(data, total_len, "%s", html_prefix); memcpy(data + html_prefix_len, markup_data, markup_len); + data[total_len - 1] = '\0'; InsertMapping(kMimeHtml, data, total_len); } @@ -353,6 +355,7 @@ void Clipboard::ReadHTML(Clipboard::Buffer buffer, string16* markup, void Clipboard::ReadBookmark(string16* title, std::string* url) const { // TODO(estade): implement this. + NOTIMPLEMENTED(); } void Clipboard::ReadData(const std::string& format, std::string* result) { |