diff --git a/buffer/buffer_seek.c b/buffer/buffer_seek.c index aba06e1..c5a6ed2 100644 --- a/buffer/buffer_seek.c +++ b/buffer/buffer_seek.c @@ -27,7 +27,10 @@ ssize_t buffer_seek(buffer* b,size_t len) { ssize_t r = buffer_feed(b); if (r < 0) return -1; if (r == 0) break; - if ((size_t)r > len) r = len; // can't happen + if ((size_t)r > len) { // awesome, we are done + b->p = len; + return r; + } len -= r; b->p = b->n = 0; }