ssnail

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

commit ebcdf1d86a6d1febb773741278cfff633fbf2013
parent 5f342330fa88a004405529545bbccc1dbb6ff940
Author: Paco Esteban <paco@e1e0.net>
Date:   Mon, 22 Jun 2020 20:41:54 +0200

better handle asprintf possible errors

Diffstat:
Mssnail.c | 16++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/ssnail.c b/ssnail.c @@ -309,16 +309,24 @@ gen_html(struct article *a) /* collect metadata from markdown */ TAILQ_FOREACH(md, &mq, entries) { if (strcmp(md->key, "title") == 0 ) { - asprintf(&a->title, "%s", md->value); + free(a->title); + if (asprintf(&a->title, "%s", md->value) == -1) + goto out; } if (strcmp(md->key, "author") == 0 ) { - asprintf(&a->author, "%s", md->value); + free(a->author); + if (asprintf(&a->author, "%s", md->value) == -1) + goto out; } if (strcmp(md->key, "date") == 0 ) { - asprintf(&a->date, "%s", md->value); + free(a->date); + if (asprintf(&a->date, "%s", md->value) == -1) + goto out; } if (strcmp(md->key, "type") == 0 ) { - asprintf(&a->type, "%s", md->value); + free(a->type); + if (asprintf(&a->type, "%s", md->value) == -1) + goto out; } }