[gtk+] mir: properly handle empty clipboard



commit a50a98f38b9a833011012f8a8f1cec01656acb6b
Author: William Hua <william hua canonical com>
Date:   Mon Jan 9 12:04:48 2017 -0500

    mir: properly handle empty clipboard
    
    https://bugzilla.gnome.org/show_bug.cgi?id=775732

 gdk/mir/gdkmirdisplay.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/gdk/mir/gdkmirdisplay.c b/gdk/mir/gdkmirdisplay.c
index 12a7679..8b21029 100644
--- a/gdk/mir/gdkmirdisplay.c
+++ b/gdk/mir/gdkmirdisplay.c
@@ -743,10 +743,16 @@ gdk_mir_display_real_convert_selection (GdkDisplay *display,
 
   paste_data = g_variant_get_fixed_array (mir_display->paste_data, &paste_size, sizeof (guchar));
   paste_header = (const gint *) paste_data;
-  paste_formats = g_ptr_array_new_full (paste_header[0], g_free);
 
-  for (i = 0; i < paste_header[0]; i++)
-    g_ptr_array_add (paste_formats, g_strndup (paste_data + paste_header[1 + 4 * i], paste_header[2 + 4 * 
i]));
+  if (paste_data)
+    {
+      paste_formats = g_ptr_array_new_full (paste_header[0], g_free);
+
+      for (i = 0; i < paste_header[0]; i++)
+        g_ptr_array_add (paste_formats, g_strndup (paste_data + paste_header[1 + 4 * i], paste_header[2 + 4 
* i]));
+    }
+  else
+    paste_formats = g_ptr_array_new_with_free_func (g_free);
 
   if (target == gdk_atom_intern_static_string ("TARGETS"))
     {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]