From: Francois Fleuret Date: Sun, 6 Mar 2011 09:44:27 +0000 (+0100) Subject: Changed how the '/' is printed after dir names. X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=commitdiff_plain;h=7059f679b97a58a432ba95a7043f7084b2f1c3e4;p=dus.git Changed how the '/' is printed after dir names. --- diff --git a/dus.c b/dus.c index 872f5c1..9330ebd 100644 --- a/dus.c +++ b/dus.c @@ -188,13 +188,14 @@ struct entry_node { }; struct entry_node *push_entry(char *name, struct entry_node *head) { + char tmp_name[PATH_MAX]; struct entry_node *result; int isdir; result = safe_malloc(sizeof(struct entry_node)); result->size = entry_size(name, &isdir); if(isdir) { - result->name = safe_malloc(sizeof(char) * strlen(name) + 2); - sprintf(result->name, "%s/", name); + snprintf(tmp_name, PATH_MAX, "%s/", name); + result->name = strdup(tmp_name); } else { result->name = strdup(name); }