Bug 1438136 - [Wayland/Clipboard] Null terminate text string returned by GetClipboardText(), r=stransky
authorEvan Klitzke <evan@eklitzke.org>
Tue, 15 May 2018 01:33:00 +0300
changeset 418520 5c1d015760f220f5438ffa23a585140db7a9801d
parent 418519 505667081ae29ee0a66ef5ba19c3870570b08564
child 418521 ae10e83d1e398d67c3e4bc0aa2e02b0b32e0f735
push id34004
push usershindli@mozilla.com
push dateWed, 16 May 2018 18:32:17 +0000
treeherdermozilla-central@d5b463283f39 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersstransky
bugs1438136
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1438136 - [Wayland/Clipboard] Null terminate text string returned by GetClipboardText(), r=stransky
widget/gtk/nsClipboardWayland.cpp
--- a/widget/gtk/nsClipboardWayland.cpp
+++ b/widget/gtk/nsClipboardWayland.cpp
@@ -666,19 +666,20 @@ void
 nsRetrievalContextWayland::TransferFastTrackClipboard(
     int aClipboardRequestNumber, GtkSelectionData *aSelectionData)
 {
     if (mClipboardRequestNumber == aClipboardRequestNumber) {
         int dataLength = gtk_selection_data_get_length(aSelectionData);
         if (dataLength > 0) {
             mClipboardDataLength = dataLength;
             mClipboardData = reinterpret_cast<char*>(
-                g_malloc(sizeof(char)*mClipboardDataLength));
+                g_malloc(sizeof(char)*(mClipboardDataLength+1)));
             memcpy(mClipboardData, gtk_selection_data_get_data(aSelectionData),
                    sizeof(char)*mClipboardDataLength);
+            mClipboardData[mClipboardDataLength] = '\0';
         }
     } else {
         NS_WARNING("Received obsoleted clipboard data!");
     }
 }
 
 const char*
 nsRetrievalContextWayland::GetClipboardData(const char* aMimeType,