Changeset 220525 in webkit


Ignore:
Timestamp:
Aug 10, 2017 4:02:33 AM (7 years ago)
Author:
Carlos Garcia Campos
Message:

[GTK] Crashes in WebCore::PasteboardHelper::fillSelectionData when source file of drag is unavailable
https://bugs.webkit.org/show_bug.cgi?id=174161

Reviewed by Xabier Rodriguez-Calvar.

In r219385 we changed the early return in fillSelectionData() to check the selection data length instead of the
data pointer. However, the gtk_selection_data_get_length() can return -1, so we need to check also if the value
less than 0. The case of setting an empty string could be valid depending on the target type, so it's better to
return early only when data lenght is less than 0 and handle the 0 length case in each target.

  • platform/gtk/PasteboardHelper.cpp:

(WebCore::PasteboardHelper::fillSelectionData):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r220523 r220525  
     12017-08-10  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Crashes in WebCore::PasteboardHelper::fillSelectionData when source file of drag is unavailable
     4        https://bugs.webkit.org/show_bug.cgi?id=174161
     5
     6        Reviewed by Xabier Rodriguez-Calvar.
     7
     8        In r219385 we changed the early return in fillSelectionData() to check the selection data length instead of the
     9        data pointer. However, the gtk_selection_data_get_length() can return -1, so we need to check also if the value
     10        less than 0. The case of setting an empty string could be valid depending on the target type, so it's better to
     11        return early only when data lenght is less than 0 and handle the 0 length case in each target.
     12
     13        * platform/gtk/PasteboardHelper.cpp:
     14        (WebCore::PasteboardHelper::fillSelectionData):
     15
    1162017-08-10  Antti Koivisto  <antti@apple.com>
    217
  • trunk/Source/WebCore/platform/gtk/PasteboardHelper.cpp

    r219385 r220525  
    210210void PasteboardHelper::fillSelectionData(GtkSelectionData* data, unsigned /* info */, SelectionData& selection)
    211211{
    212     if (!gtk_selection_data_get_length(data))
     212    if (gtk_selection_data_get_length(data) < 0)
    213213        return;
    214214
     
    229229        // Give preference to text/uri-list here, as it can hold more
    230230        // than one URI but still take  the label if there is one.
    231         if (!selection.hasURIList())
     231        if (!selection.hasURIList() && !pieces.isEmpty())
    232232            selection.setURIList(pieces[0]);
    233233        if (pieces.size() > 1)
    234234            selection.setText(pieces[1]);
    235     } else if (target == unknownAtom) {
     235    } else if (target == unknownAtom && gtk_selection_data_get_length(data)) {
    236236        GRefPtr<GVariant> variant = g_variant_new_parsed(reinterpret_cast<const char*>(gtk_selection_data_get_data(data)));
    237237
Note: See TracChangeset for help on using the changeset viewer.