diff options
-rw-r--r-- | src/opk.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -251,6 +251,7 @@ opkg_opk_opk_list_members(struct opkg_opk_opk *opk) /* Build singly-linked list and find maximum column widths. */ head = NULL; + tail = NULL; uname_len_max = 0; gname_len_max = 0; size_max = 0; @@ -279,14 +280,16 @@ opkg_opk_opk_list_members(struct opkg_opk_opk *opk) _opkg_opk_opk_free_inner(opk); return OPKG_OPK_ERROR; } - tail->next = NULL; + if (tail != NULL) { + tail->next = NULL; + } /* Print and free members. */ ret = OPKG_OPK_OK; size_len_max = lrint(ceil(log10(size_max))); snprintf(fmt, sizeof(fmt), "%%c%%s %%-%zus/%%-%zus %%%lid %%s %%s\n", - uname_len, gname_len, size_len_max); - len = 35 + uname_len + gname_len + size_len_max; + uname_len_max, gname_len_max, size_len_max); + len = 35 + uname_len_max + gname_len_max + size_len_max; for (member = head; member != NULL;) { if (member->mode & 00400) mode[0] = 'r'; else mode[0] = '-'; if (member->mode & 00200) mode[1] = 'w'; else mode[1] = '-'; |