[GLIB] GVariant floating references are not correctly handled by GRefPtr
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 20 Jan 2014 08:01:16 +0000 (08:01 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 20 Jan 2014 08:01:16 +0000 (08:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=127246

Reviewed by Martin Robinson.

Source/WebCore:

Do not adopt GVariant floating references, they will be converted
to a full reference by GRefPtr.

* platform/gtk/PasteboardHelper.cpp:
(WebCore::PasteboardHelper::fillSelectionData):
(WebCore::PasteboardHelper::fillDataObjectFromDropData):

Source/WTF:

GRefPtr should always use g_variant_ref_sink to deal with GVariant
floating references. In case of full references,
g_variant_ref_sink calls g_variant_ref, so it's safe to use it always.

* wtf/gobject/GRefPtr.cpp:
(WTF::refGPtr): Use g_variant_ref_sink().

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

Source/WTF/ChangeLog
Source/WTF/wtf/gobject/GRefPtr.cpp
Source/WebCore/ChangeLog
Source/WebCore/platform/gtk/PasteboardHelper.cpp

index b918cf4..06a545c 100644 (file)
@@ -1,3 +1,17 @@
+2014-01-19  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GLIB] GVariant floating references are not correctly handled by GRefPtr
+        https://bugs.webkit.org/show_bug.cgi?id=127246
+
+        Reviewed by Martin Robinson.
+
+        GRefPtr should always use g_variant_ref_sink to deal with GVariant
+        floating references. In case of full references,
+        g_variant_ref_sink calls g_variant_ref, so it's safe to use it always.
+
+        * wtf/gobject/GRefPtr.cpp:
+        (WTF::refGPtr): Use g_variant_ref_sink().
+
 2014-01-18  Anders Carlsson  <andersca@apple.com>
 
         Remove support for the viewsource attribute
index b6a31ac..52a9a39 100644 (file)
@@ -98,7 +98,7 @@ template <> void derefGPtr(GBytes* ptr)
 template <> GVariant* refGPtr(GVariant* ptr)
 {
     if (ptr)
-        g_variant_ref(ptr);
+        g_variant_ref_sink(ptr);
     return ptr;
 }
 
index 3e971ca..056d6b4 100644 (file)
@@ -1,3 +1,17 @@
+2014-01-19  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GLIB] GVariant floating references are not correctly handled by GRefPtr
+        https://bugs.webkit.org/show_bug.cgi?id=127246
+
+        Reviewed by Martin Robinson.
+
+        Do not adopt GVariant floating references, they will be converted
+        to a full reference by GRefPtr.
+
+        * platform/gtk/PasteboardHelper.cpp:
+        (WebCore::PasteboardHelper::fillSelectionData):
+        (WebCore::PasteboardHelper::fillDataObjectFromDropData):
+
 2014-01-19  Jinwoo Song  <jinwoo7.song@samsung.com>
 
         Use unsigned type for the size of CSSParserValueList
index a335a7d..fa7bc7b 100644 (file)
@@ -197,7 +197,7 @@ void PasteboardHelper::fillSelectionData(GtkSelectionData* selectionData, guint
             g_variant_builder_add_parsed(&builder, dictItem.get());
         }
 
-        GRefPtr<GVariant> variant = adoptGRef(g_variant_builder_end(&builder));
+        GRefPtr<GVariant> variant = g_variant_builder_end(&builder);
         GOwnPtr<gchar> serializedVariant(g_variant_print(variant.get(), TRUE));
         gtk_selection_data_set(selectionData, unknownAtom, 1, reinterpret_cast<const guchar*>(serializedVariant.get()), strlen(serializedVariant.get()));
     }
@@ -256,7 +256,7 @@ void PasteboardHelper::fillDataObjectFromDropData(GtkSelectionData* data, guint
         if (pieces.size() > 1)
             dataObject->setText(pieces[1]);
     } else if (target == unknownAtom) {
-        GRefPtr<GVariant> variant = adoptGRef(g_variant_new_parsed(reinterpret_cast<const char*>(gtk_selection_data_get_data(data))));
+        GRefPtr<GVariant> variant = g_variant_new_parsed(reinterpret_cast<const char*>(gtk_selection_data_get_data(data)));
 
         GOwnPtr<gchar> key;
         GOwnPtr<gchar> value;