summaryrefslogtreecommitdiff
path: root/mozilla-1438136.patch
blob: 6462a41148f6431a2927fb82a9bb4478eddb76df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

# HG changeset patch
# User Evan Klitzke <evan@eklitzke.org>
# Date 1526337180 -10800
# Node ID 5c1d015760f220f5438ffa23a585140db7a9801d
# Parent  505667081ae29ee0a66ef5ba19c3870570b08564
Bug 1438136 - [Wayland/Clipboard] Null terminate text string returned by GetClipboardText(), r=stransky

diff --git a/widget/gtk/nsClipboardWayland.cpp b/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,

bgstack15