Skip to content

Commit db5e211

Browse files
committed
Avoid segfault when all messages are excluded - fixes #29
1 parent 80a82d9 commit db5e211

File tree

1 file changed

+27
-23
lines changed

1 file changed

+27
-23
lines changed

src/hypermail.c

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,7 @@ int main(int argc, char **argv)
604604
}
605605
if (set_increment) {
606606
int num_displayable;
607+
int num_added;
607608
if (set_linkquotes)
608609
replylist = NULL;
609610
/* we have to start with the msgnum - 1 so that the rest of the
@@ -613,29 +614,32 @@ int main(int argc, char **argv)
613614
amount_old = max_msgnum + 1; /* counts gaps as messages */
614615

615616
/* start numbering at this number */
616-
amount_new = num_displayable + parsemail(set_mbox, use_stdin, set_readone, set_increment, set_dir, set_inlinehtml, amount_old);
617-
if (set_linkquotes)
618-
analyze_headers(max_msgnum + 1);
619-
620-
/* write the index of msgno/msgid_hash filenames */
621-
if (set_nonsequential)
622-
write_messageindex(0, max_msgnum + 1);
623-
624-
writearticles(amount_old, max_msgnum + 1);
625-
626-
/* JK: in function of other hypermail configuration options,
627-
delete_incremental will continuous escape and add more markup
628-
to non-deleted messages that are replies to deleted messages.
629-
Thus, a setup option to disable it */
630-
if (set_delete_incremental && deletedlist)
631-
update_deletions(amount_old);
632-
633-
if (set_show_msg_links) {
634-
fixnextheader(set_dir, amount_old, -1);
635-
for (i = amount_old; i <= max_msgnum; ++i) {
636-
if (set_showreplies)
637-
fixreplyheader(set_dir, i, 0, amount_old);
638-
fixthreadheader(set_dir, i, amount_old);
617+
num_added = parsemail(set_mbox, use_stdin, set_readone, set_increment, set_dir, set_inlinehtml, amount_old);
618+
if (num_added > 0) {
619+
amount_new = num_displayable + num_added;
620+
if (set_linkquotes)
621+
analyze_headers(max_msgnum + 1);
622+
623+
/* write the index of msgno/msgid_hash filenames */
624+
if (set_nonsequential)
625+
write_messageindex(0, max_msgnum + 1);
626+
627+
writearticles(amount_old, max_msgnum + 1);
628+
629+
/* JK: in function of other hypermail configuration options,
630+
delete_incremental will continuous escape and add more markup
631+
to non-deleted messages that are replies to deleted messages.
632+
Thus, a setup option to disable it */
633+
if (set_delete_incremental && deletedlist)
634+
update_deletions(amount_old);
635+
636+
if (set_show_msg_links) {
637+
fixnextheader(set_dir, amount_old, -1);
638+
for (i = amount_old; i <= max_msgnum; ++i) {
639+
if (set_showreplies)
640+
fixreplyheader(set_dir, i, 0, amount_old);
641+
fixthreadheader(set_dir, i, amount_old);
642+
}
639643
}
640644
}
641645
}

0 commit comments

Comments
 (0)