scribo

Email-based phlog generator
git clone git://git.z3bra.org/scribo.git
Log | Files | Refs | README | LICENSE

commit 4c3057e4dbe6af6568d7cd86b0ccd36bd46f602a
parent 7f49155fea2cf3104dfa570f8a27e27bcbf111db
Author: Willy Goiffon <dev@z3bra.org>
Date:   Sun, 20 Sep 2020 12:06:29 +0200

Move errors in parsing headers to the called function

Diffstat:
Mrfc5322.c | 1-
Mscribo.c | 15++++++++-------
2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/rfc5322.c b/rfc5322.c @@ -41,7 +41,6 @@ rfc5322_headerbody(const char *s) return strsep(&p, "\r\n"); } - size_t rfc5322_unfold(char *body, char *line, size_t n) { diff --git a/scribo.c b/scribo.c @@ -146,7 +146,7 @@ parseheaders(FILE *fp, struct headers *head) char *buf = NULL; size_t bufsiz = 0; ssize_t len; - struct hdr *h; + struct hdr *h = NULL; SLIST_INIT(head); @@ -162,10 +162,13 @@ parseheaders(FILE *fp, struct headers *head) h = saveheader(head, buf); } - free(buf); - - if (len < 0) + if (len < 0) { + perror("getline"); + free(buf); return -1; + } + + free(buf); return 0; } @@ -364,10 +367,8 @@ main(int argc, char *argv[]) return -1; } - if (parseheaders(in, &headers) < 0) { - perror("header section"); + if (parseheaders(in, &headers) < 0) return -1; - } if (verifyheaders(&headers) < 0) return -1;