summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIngo Saitz <[email protected]>2013-03-27 14:38:00 +0100
committerIngo Saitz <[email protected]>2013-03-27 14:38:00 +0100
commit4421eb314b10868707bea9f3375ff61a174f4b2b (patch)
treedadc043d7c158136aeb204e7b14f31c473d1e20f /src
parent19da01b11830015657c83235a48934a78b693990 (diff)
downloadengrampa-4421eb314b10868707bea9f3375ff61a174f4b2b.tar.bz2
engrampa-4421eb314b10868707bea9f3375ff61a174f4b2b.tar.xz
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.
Diffstat (limited to 'src')
-rw-r--r--src/fr-window.c10
1 files 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;
}