nightmaremail

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit ec5d57bd0530d190fb0eec2552caadcc7944ac02
parent a524a360927f79dd29d2c56b46892828eb79a5fa
Author: Rolf Eike Beer <eike@sf-mail.de>
Date:   Mon, 15 Jun 2020 20:23:47 +0200

fix read() return value handling in getln2()

If substdio_get() return -1 this would decrease the length setting in the passed
substdio.

Diffstat:
Mgetln2.c | 6++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/getln2.c b/getln2.c @@ -17,7 +17,7 @@ int sep; sa->len = 0; for (;;) { - ssize_t n; + ssize_t n, m; n = substdio_feed(ss); if (n < 0) return -1; if (n == 0) { *clen = 0; return 0; } @@ -26,6 +26,8 @@ int sep; if (i < n) { substdio_SEEK(ss,*clen = i + 1); *cont = x; return 0; } if (!stralloc_readyplus(sa,n)) return -1; i = sa->len; - sa->len = i + substdio_get(ss,sa->s + i,n); + m = substdio_get(ss,sa->s + i,n); + if (m != -1) + sa->len = i + m; } }