tMove errors in parsing headers to the called function - scribo - Email-based phlog generator
(HTM) git clone git://git.z3bra.org/scribo.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 4c3057e4dbe6af6568d7cd86b0ccd36bd46f602a
(DIR) parent 7f49155fea2cf3104dfa570f8a27e27bcbf111db
(HTM) 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:
M rfc5322.c | 1 -
M scribo.c | 15 ++++++++-------
2 files changed, 8 insertions(+), 8 deletions(-)
---
(DIR) diff --git a/rfc5322.c b/rfc5322.c
t@@ -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)
{
(DIR) diff --git a/scribo.c b/scribo.c
t@@ -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);
t@@ -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;
}
t@@ -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;