From 72407171983277df44c1cfe62e3f7abdff9cfa6d Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Fri, 2 Feb 2001 22:09:11 +0000 Subject: [PATCH] get_max_column_count(), columns_sort_list(): fixed to work properly with empty list git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1176 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/core/misc.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/core/misc.c b/src/core/misc.c index 48ab992f..b9bc70c7 100644 --- a/src/core/misc.c +++ b/src/core/misc.c @@ -618,6 +618,11 @@ int get_max_column_count(GSList *items, COLUMN_LEN_FUNC len_func, int ret, len, n, col, max_columns; items_count = g_slist_length(items); + if (items_count == 0) { + *save_column_widths = NULL; + *rows = 0; + return 0; + } max_columns = max_width/(item_extra+item_min_size); columns = g_new0(int *, max_columns); @@ -680,6 +685,9 @@ GSList *columns_sort_list(GSList *list, int rows) GSList *tmp, *sorted; int row, skip; + if (list == NULL || rows == 0) + return list; + sorted = NULL; for (row = 0; row < rows; row++) {