lib: Fixed another bufio bug.
authorFredrik Tolf <fredrik@dolda2000.com>
Sun, 1 May 2016 02:57:51 +0000 (04:57 +0200)
committerFredrik Tolf <fredrik@dolda2000.com>
Sun, 1 May 2016 02:57:51 +0000 (04:57 +0200)
lib/bufio.c

index 83963b3..fe5d005 100644 (file)
@@ -259,8 +259,10 @@ ssize_t biowritesome(struct bufio *bio, const void *data, size_t len)
     if(bio->wh == bio->wbuf.d)
        bio->wh = bio->wbuf.d = 0;
     if(bio->wbuf.d == bio->wbuf.s) {
-       if(bio->wh > 0)
+       if(bio->wh > 0) {
            memmove(bio->wbuf.b, bio->wbuf.b + bio->wh, bio->wbuf.d -= bio->wh);
+           bio->wh = 0;
+       }
     }
     ret = min(len, bio->wbuf.s - bio->wbuf.d);
     memcpy(bio->wbuf.b + bio->wbuf.d, data, ret);