2007-11-04 Alp Toker <alp@atoker.com>
authoralp <alp@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 4 Nov 2007 15:03:13 +0000 (15:03 +0000)
committeralp <alp@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 4 Nov 2007 15:03:13 +0000 (15:03 +0000)
        Reviewed by Alexey Proskuryakov.

        Fix a crash when no clipboard text is available

        * platform/gtk/PasteboardGtk.cpp:
        (WebCore::Pasteboard::plainText):

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

WebCore/ChangeLog
WebCore/platform/gtk/PasteboardGtk.cpp

index 39d3af1ca0851c9f3a9b2ab3d0a2ab2ad8ea3e9e..7996014b05bf41e21f037158dda4d4a7dd67afe6 100644 (file)
@@ -1,3 +1,12 @@
+2007-11-04  Alp Toker  <alp@atoker.com>
+
+        Reviewed by Alexey Proskuryakov.
+
+        Fix a crash when no clipboard text is available
+
+        * platform/gtk/PasteboardGtk.cpp:
+        (WebCore::Pasteboard::plainText):
+
 2007-11-03  Darin Adler  <darin@apple.com>
 
         Reviewed by Maciej.
index da497f6b33502eca6b00e89ced9f577fb1f639bd..6301aed98d19e274099e0629c983ddc02f5e7d79 100644 (file)
@@ -117,9 +117,12 @@ String Pasteboard::plainText(Frame*)
     GtkClipboard* clipboard = gtk_clipboard_get_for_display(gdk_display_get_default(), GDK_SELECTION_CLIPBOARD);
 
     gchar* utf8 = gtk_clipboard_wait_for_text(clipboard);
+
+    if (!utf8)
+        return String();
+
     String text = String::fromUTF8(utf8);
-    if (utf8)
-        g_free(utf8);
+    g_free(utf8);
 
     return text;
 }