diff options
Diffstat (limited to 'mozilla-1631061-2.patch')
-rw-r--r-- | mozilla-1631061-2.patch | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/mozilla-1631061-2.patch b/mozilla-1631061-2.patch new file mode 100644 index 0000000..ae90baa --- /dev/null +++ b/mozilla-1631061-2.patch @@ -0,0 +1,91 @@ +changeset: 567293:4d5e5e9f146e +tag: tip +parent: 567291:3bdf0c33844f +user: stransky <stransky@redhat.com> +date: Fri Jan 29 12:13:15 2021 +0100 +files: widget/gtk/nsClipboardWayland.cpp +description: +Bug 1631061 [Wayland] Clear clipboard content when gtk_clipboard_request_contents() fails, r?jhorak + +Differential Revision: https://phabricator.services.mozilla.com/D103461 + + +diff --git a/widget/gtk/nsClipboardWayland.cpp b/widget/gtk/nsClipboardWayland.cpp +--- a/widget/gtk/nsClipboardWayland.cpp ++++ b/widget/gtk/nsClipboardWayland.cpp +@@ -842,7 +842,8 @@ struct FastTrackClipboard { + + static void wayland_clipboard_contents_received( + GtkClipboard* clipboard, GtkSelectionData* selection_data, gpointer data) { +- LOGCLIP(("wayland_clipboard_contents_received() callback\n")); ++ LOGCLIP(("wayland_clipboard_contents_received() selection_data = %p\n", ++ selection_data)); + FastTrackClipboard* fastTrack = static_cast<FastTrackClipboard*>(data); + fastTrack->mRetrievalContex->TransferFastTrackClipboard( + fastTrack->mClipboardRequestNumber, selection_data); +@@ -851,24 +852,34 @@ static void wayland_clipboard_contents_r + + void nsRetrievalContextWayland::TransferFastTrackClipboard( + int aClipboardRequestNumber, GtkSelectionData* aSelectionData) { +- LOGCLIP(("nsRetrievalContextWayland::TransferFastTrackClipboard()\n")); ++ LOGCLIP( ++ ("nsRetrievalContextWayland::TransferFastTrackClipboard(), " ++ "aSelectionData = %p\n", ++ aSelectionData)); ++ ++ int dataLength = gtk_selection_data_get_length(aSelectionData); ++ if (dataLength < 0) { ++ LOGCLIP( ++ (" gtk_clipboard_request_contents() failed to get clipboard " ++ "data!\n")); ++ ReleaseClipboardData(mClipboardData); ++ return; ++ } + + if (mClipboardRequestNumber == aClipboardRequestNumber) { + LOGCLIP((" request number matches\n")); +- int dataLength = gtk_selection_data_get_length(aSelectionData); +- if (!dataLength) { +- LOGCLIP( +- (" gtk_selection_data_get_length() returned 0 data length!\n")); +- return; +- } + LOGCLIP((" fastracking %d bytes of data.\n", dataLength)); + mClipboardDataLength = dataLength; +- mClipboardData = reinterpret_cast<char*>( +- g_malloc(sizeof(char) * (mClipboardDataLength + 1))); +- memcpy(mClipboardData, gtk_selection_data_get_data(aSelectionData), +- sizeof(char) * mClipboardDataLength); +- mClipboardData[mClipboardDataLength] = '\0'; +- LOGCLIP((" done, mClipboardData = %p\n", mClipboardData)); ++ if (dataLength > 0) { ++ mClipboardData = reinterpret_cast<char*>( ++ g_malloc(sizeof(char) * (mClipboardDataLength + 1))); ++ memcpy(mClipboardData, gtk_selection_data_get_data(aSelectionData), ++ sizeof(char) * mClipboardDataLength); ++ mClipboardData[mClipboardDataLength] = '\0'; ++ LOGCLIP((" done, mClipboardData = %p\n", mClipboardData)); ++ } else { ++ ReleaseClipboardData(mClipboardData); ++ } + } else { + LOGCLIP((" request number does not match!\n")); + NS_WARNING("Received obsoleted clipboard data!"); +@@ -952,11 +963,10 @@ void nsRetrievalContextWayland::ReleaseC + const char* aClipboardData) { + LOGCLIP(("nsRetrievalContextWayland::ReleaseClipboardData [%p]\n", + aClipboardData)); +- +- NS_ASSERTION(aClipboardData == mClipboardData, +- "Releasing unknown clipboard data!"); +- g_free((void*)aClipboardData); +- ++ if (aClipboardData != mClipboardData) { ++ NS_WARNING("Wayland clipboard: Releasing unknown clipboard data!"); ++ } ++ g_free((void*)mClipboardData); ++ mClipboardDataLength = 0; + mClipboardData = nullptr; +- mClipboardDataLength = 0; + } + |