summaryrefslogtreecommitdiff
path: root/src/libstddjb/slurpn.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstddjb/slurpn.c')
-rw-r--r--src/libstddjb/slurpn.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libstddjb/slurpn.c b/src/libstddjb/slurpn.c
index c9c5c11..ee5157f 100644
--- a/src/libstddjb/slurpn.c
+++ b/src/libstddjb/slurpn.c
@@ -16,7 +16,7 @@ int slurpn (int fd, stralloc *sa, size_t max)
for (;;)
{
ssize_t r ;
- size_t n = max && sa->len + N > max ? max - sa->len : N ;
+ size_t n = max && sa->len - sabase + N > max ? max - (sa->len - sabase) : N ;
if (!n) { errno = ENOBUFS ; goto err ; }
if (!stralloc_readyplus(sa, n)) break ;
r = fd_read(fd, sa->s + sa->len, n) ;