diff --git a/src/parser.c b/src/parser.c

index 04501b6b644af28abe7843076ae593b7165912b2..579415150f842557b6faf4097a63aac9324928fb 100644

--- a/src/parser.c

+++ b/src/parser.c

@@ -46,7 +46,7 @@ ssize_t n = BIO_read(p->f, &p->buf[p->bufln], p->bufsz - p->bufln - 1);

if (n == -1) {

return -1;

} else if (n == 0) {

- eof = 1;

+ eof = p->bufln == 0;

break;

}

p->bufln += n;