commit 5a41d1451bdc34347c9eb86f427e534ef58876bd
parent 5d5304c0ae398320d76fbc52d9cee5b679f0aa78
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Thu, 28 Nov 2019 12:22:21 +0100
Fix an bug when the read line is greater than 128 chars
Diffstat:
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/htgop_reader.h b/src/htgop_reader.h
@@ -58,7 +58,8 @@ read_line(struct reader* rdr)
/* Ensure that the whole line is read */
while(!strrchr(rdr->line, '\n') && !feof(rdr->stream)) {
- CHK(fgets(sa_add(rdr->line, (size_t)chunk), chunk, rdr->stream));
+ char* more = sa_add(rdr->line, (size_t)chunk);
+ CHK(fgets(more-1/*prev null char*/, chunk+1/*prev null char*/, rdr->stream));
}
rdr->line[strcspn(rdr->line, "#\n\r")] = '\0'; /* Rm new line & comments */