# HG changeset patch # User zas_ # Date 1207409019 0 # Node ID 249a9a6cd27f896fedc98f61e535577221f31205 # Parent fa7d69e7d02d4a0d3499b19cbad260c216f97a3e Improve remove_trailing_slash() so it allocates no more than needed bytes and remove all trailing slashes instead only one. diff -r fa7d69e7d02d -r 249a9a6cd27f src/ui_tabcomp.c --- a/src/ui_tabcomp.c Sat Apr 05 11:59:29 2008 +0000 +++ b/src/ui_tabcomp.c Sat Apr 05 15:23:39 2008 +0000 @@ -814,15 +814,14 @@ gchar *remove_trailing_slash(const gchar *path) { - gchar *ret; gint l; + if (!path) return NULL; - ret = g_strdup(path); - l = strlen(ret); - if (l > 1 && ret[l - 1] == '/') ret[l - 1] = '\0'; + l = strlen(path); + while (l > 1 && path[l - 1] == '/') l--; - return ret; + return g_strndup(path, l); } static void tab_completion_select_cancel_cb(FileDialog *fd, gpointer data)