From a83661b45a90ec614f663684b1c685578728914c Mon Sep 17 00:00:00 2001 From: gunnar_g Date: Mon, 2 Mar 2009 23:06:44 +0000 Subject: [PATCH] Solving valgrind errors. The error was:"Source and destination overlap in mempcpy" --- src/treeview.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/treeview.c b/src/treeview.c index efb1bdd9..2aa3ccd4 100644 --- a/src/treeview.c +++ b/src/treeview.c @@ -2678,6 +2678,7 @@ treeview_create_country_list(const GPtrArray *country_list) // This variable will be used to lookup gchar* previous_element; gchar* current_country; + gchar* buf2; for(i=0;ilen;i++) { @@ -2688,7 +2689,9 @@ treeview_create_country_list(const GPtrArray *country_list) if (g_str_has_prefix(current_country,G_DIR_SEPARATOR_S)) { // Strip leading directory delimiter - sprintf(current_country, "%.*s", (gint)strlen(current_country) - 1, ¤t_country[1]); + buf2 = g_strdup((gchar*)current_country); + sprintf(current_country, "%.*s", (gint)strlen(current_country) - 1, &buf2[1]); + g_free(buf2); } dir_split_up = g_strsplit_set (current_country, G_DIR_SEPARATOR_S, -1); // We only go up to the before last column. We don't want to show the