From 5fae797e4191a970deade1e2a20cccd834823ca9 Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Wed, 5 Jul 2017 23:31:33 +0200 Subject: [PATCH] Do not increase size in _fgets if we reach the EOF. --- m-string.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/m-string.h b/m-string.h index 12781dc4..80bebb29 100644 --- a/m-string.h +++ b/m-string.h @@ -552,8 +552,11 @@ string_fgets(string_t v, FILE *f, string_fgets_t arg) } STRING_CONTRACT(v); return; - } else if (p == NULL) + } else if (p == NULL && !feof(f)) { + /* The string buffer is not big enough: + increase it and continue reading */ stringi_fit2size (v, v->alloc + v->alloc/2); + } } STRING_CONTRACT (v); }