From 02e28520c4b36386258cc74a2534970c177ec6c2 Mon Sep 17 00:00:00 2001 From: Ralph Corderoy Date: Sun, 16 Oct 2016 12:23:57 +0100 Subject: [PATCH] Don't increment bytes_read if returning EOF. Don't know if this was actually causing a problem, or if it was wrong, but bytes_read was always being incremented even if the later test showed readpos was to be left unincremented and EOF returned instead. All tests still pass so any breakage must be subtle! --- sbr/m_getfld.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sbr/m_getfld.c b/sbr/m_getfld.c index a7622b56..3a6d50eb 100644 --- a/sbr/m_getfld.c +++ b/sbr/m_getfld.c @@ -450,12 +450,12 @@ read_more (m_getfld_state_t s) { but EOF is typically 0xffffffff. */ static int Getc (m_getfld_state_t s) { - if (s->end - s->readpos < 1 && read_more (s) == 0) { + if ((s->end - s->readpos < 1 && read_more (s) == 0) || + s->readpos >= s->end) return EOF; - } else { - ++s->bytes_read; - return s->readpos < s->end ? (unsigned char) *s->readpos++ : EOF; - } + + s->bytes_read++; + return (unsigned char)*s->readpos++; } static int -- 2.56.0