From 2501fb1ad574dda6d2f38c34b71033189a97340e Mon Sep 17 00:00:00 2001 From: Yorhel Date: Sun, 20 Jan 2019 16:43:55 +0100 Subject: [PATCH] Fix crash when attempting to sort an empty directory I had taken care to not sort empty directories during dirlist_open(), but forgot that manual user actions can still cause dirlist_set_sort() to be called, which does not handle empty directories. Reported by Alex Wilson. --- src/dirlist.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/dirlist.c b/src/dirlist.c index 3b4c655..da51a98 100644 --- a/src/dirlist.c +++ b/src/dirlist.c @@ -371,7 +371,8 @@ void dirlist_set_sort(int col, int desc, int df) { dirlist_sort_df = df; /* sort the list (excluding the parent, which is always on top) */ - head_real = dirlist_sort(head_real); + if(head_real) + head_real = dirlist_sort(head_real); if(dirlist_parent) dirlist_parent->next = head_real; else