ssnail

crappy and opinionated static site generator
git clone https://git.e1e0.net/ssnail.git
Log | Files | Refs | README | LICENSE

commit 2db36a53521a53aceeb671878d5bd93dabe571c1
parent 1f7075c946aca465c649a85f1a3aa4df45c25a68
Author: Paco Esteban <paco@e1e0.net>
Date:   Thu,  2 Jul 2020 16:02:11 +0200

fix some segfaults if metadata is not present on md

Diffstat:
Mssnail.c | 14+++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/ssnail.c b/ssnail.c @@ -86,7 +86,7 @@ main(int argc, char *argv[]) int ch, index = 0, rss = 0, force = 0; char *header_tpl = NULL, *footer_tpl = NULL, - *index_listing = "", *rss_listing = "", + *index_listing = NULL, *rss_listing = NULL, *title = NULL, *url = NULL; header_tpl = strdup(HEADER); @@ -99,6 +99,16 @@ main(int argc, char *argv[]) error = ssnail_error_from_errno("footer_tpl def"); goto done; } + index_listing = strdup(""); + if (index_listing == NULL) { + error = ssnail_error_from_errno("index_listing def"); + goto done; + } + rss_listing = strdup(""); + if (rss_listing == NULL) { + error = ssnail_error_from_errno("rss_listing def"); + goto done; + } while ((ch = getopt(argc, argv, "Ff:h:irt:u:")) != -1) { switch (ch) { @@ -493,6 +503,8 @@ sort_articleq(struct listhead *h) /* move element to the "right" until is the smallest value */ /* or we're at the end of the list */ while ((a2 = LIST_NEXT(a1, entries)) != NULL) { + if (!a1->date || !a2->date) + return ssnail_error_msg(2, "cmp date NULL"); if (strcmp(a1->date, a2->date) < 0) { LIST_REMOVE(a2, entries); LIST_INSERT_BEFORE(a1, a2, entries);