[GTK] Fix runtime critical warnings when writing to the clipboard after r173687
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 17 Sep 2014 16:12:50 +0000 (16:12 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 17 Sep 2014 16:12:50 +0000 (16:12 +0000)
https://bugs.webkit.org/show_bug.cgi?id=136891

Reviewed by Philippe Normand.

* platform/gtk/PasteboardHelper.cpp:
(WebCore::PasteboardHelper::writeClipboardContents): Check passed
callback is not null before trying to ref/unref it since
g_closure_ref/unref are not null safe.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@173692 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/gtk/PasteboardHelper.cpp

index 620d087..571495c 100644 (file)
@@ -1,3 +1,15 @@
+2014-09-17  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GTK] Fix runtime critical warnings when writing to the clipboard after r173687
+        https://bugs.webkit.org/show_bug.cgi?id=136891
+
+        Reviewed by Philippe Normand.
+
+        * platform/gtk/PasteboardHelper.cpp:
+        (WebCore::PasteboardHelper::writeClipboardContents): Check passed
+        callback is not null before trying to ref/unref it since
+        g_closure_ref/unref are not null safe.
+
 2014-09-17  Zan Dobersek  <zdobersek@igalia.com>
 
         [GTK] Add a helper function for display system deduction
index 2869d25..6844a80 100644 (file)
@@ -311,11 +311,12 @@ void PasteboardHelper::writeClipboardContents(GtkClipboard* clipboard, SmartPast
     if (numberOfTargets > 0 && table) {
         settingClipboardDataObject = dataObject;
 
-        if (gtk_clipboard_set_with_data(clipboard, table, numberOfTargets, getClipboardContentsCallback, clearClipboardContentsCallback, g_closure_ref(callback)))
+        if (gtk_clipboard_set_with_data(clipboard, table, numberOfTargets, getClipboardContentsCallback, clearClipboardContentsCallback, callback ? g_closure_ref(callback) : nullptr))
             gtk_clipboard_set_can_store(clipboard, nullptr, 0);
         else {
             // When gtk_clipboard_set_with_data fails the callbacks are ignored, so we need to release the reference we were passing to clearClipboardContentsCallback.
-            g_closure_unref(callback);
+            if (callback)
+                g_closure_unref(callback);
         }
 
         settingClipboardDataObject = nullptr;