From: Carlos Garcia Campos <carlosgc@webkit.org>
Subject: Add NULL check to convertToUTF8String()
Bug: https://bugs.webkit.org/show_bug.cgi?id=133904
Origin: http://trac.webkit.org/changeset/178339
Index: webkitgtk/Source/WebCore/bindings/gobject/ConvertToUTF8String.cpp
===================================================================
--- webkitgtk.orig/Source/WebCore/bindings/gobject/ConvertToUTF8String.cpp
+++ webkitgtk/Source/WebCore/bindings/gobject/ConvertToUTF8String.cpp
@@ -29,11 +29,14 @@
 
 gchar* convertToUTF8String(WTF::String const& s)
 {
+    if (s.isNull())
+        return 0;
+
     return g_strdup(s.utf8().data());
 }
 
 gchar* convertToUTF8String(WebCore::URL const& s)
 {
-    return g_strdup(s.string().utf8().data());
+    return convertToUTF8String(s.string());
 }
 
Index: webkitgtk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/DOMNodeTest.cpp
===================================================================
--- webkitgtk.orig/Tools/TestWebKitAPI/Tests/WebKit2Gtk/DOMNodeTest.cpp
+++ webkitgtk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/DOMNodeTest.cpp
@@ -108,6 +108,9 @@ private:
         // Body shouldn't have any children at this point.
         g_assert(!webkit_dom_node_has_child_nodes(WEBKIT_DOM_NODE(body)));
 
+        // The value of a non-existent attribute should be null, not an empty string
+        g_assert(!webkit_dom_html_body_element_get_background(WEBKIT_DOM_HTML_BODY_ELEMENT(body)));
+
         // Insert one P element.
         WebKitDOMElement* p = webkit_dom_document_create_element(document, "P", 0);
         g_assert(WEBKIT_DOM_IS_HTML_ELEMENT(p));
