From 4421eb314b10868707bea9f3375ff61a174f4b2b Mon Sep 17 00:00:00 2001 From: Ingo Saitz Date: Wed, 27 Mar 2013 14:38:00 +0100 Subject: Fix garbled dir on extraction (closes GH-1) Add a missing \0 on receiving the char* from the XDS_ATOM. g_strndup is needed, because the returned char* is of fixed length and one byte too small if it has no final \0. --- src/fr-window.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/fr-window.c b/src/fr-window.c index 7ac8a2d..0b36aea 100644 --- a/src/fr-window.c +++ b/src/fr-window.c @@ -4195,6 +4195,8 @@ file_list_drag_end (GtkWidget *widget, static char * get_xds_atom_value (GdkDragContext *context) { + gint actual_length; + char *data; char *ret; g_return_val_if_fail (context != NULL, NULL); @@ -4203,9 +4205,13 @@ get_xds_atom_value (GdkDragContext *context) if (gdk_property_get (gdk_drag_context_get_source_window (context), XDS_ATOM, TEXT_ATOM, 0, MAX_XDS_ATOM_VAL_LEN, - FALSE, NULL, NULL, NULL, - (unsigned char **) &ret)) + FALSE, NULL, NULL, &actual_length, + (unsigned char **) &data)) { + /* add not included \0 to the end of the string */ + ret = g_strndup ((gchar *) data, actual_length); + g_free (data); return ret; + } return NULL; } -- cgit v1.2.1