From 0903b077d2b18e1144f34fa59dba6054b7e9fc98 Mon Sep 17 00:00:00 2001 From: Ben Schmidt Date: Mon, 23 Jan 2012 18:30:06 +1100 Subject: [PATCH] Handle edge cases at end-of-file properly. --- src/prepstdreply.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/prepstdreply.c b/src/prepstdreply.c index cc07aa7f..28e68f8d 100644 --- a/src/prepstdreply.c +++ b/src/prepstdreply.c @@ -959,7 +959,7 @@ char *get_processed_text_line(text *txt, int headers, const char *listaddr, const char *listdelim, const char *listdir) { - char *line = NULL; + char *line; const char *item; char *pos; char *tmp, *spc; @@ -971,6 +971,7 @@ char *get_processed_text_line(text *txt, int headers, int swallow; for (;;) { + line = NULL; while (txt->src != NULL) { if (txt->src->upcoming != NULL) { if (txt->src->prefix != NULL) { @@ -1002,7 +1003,11 @@ char *get_processed_text_line(text *txt, int headers, if (txt->src->upcoming != NULL) continue; close_source(txt); } - if (line == NULL) return NULL; + if (line == NULL) { + if (peeking) return mystrdup(""); + if (prev != NULL) return prev; + return NULL; + } tmp = unistr_escaped_to_utf8(line); myfree(line); -- 2.47.3