X-Git-Url: http://dolda2000.com/gitweb/?p=ashd.git;a=blobdiff_plain;f=lib%2Fbufio.c;h=1929d31620c4f19885c714b68592d01cfd159ab1;hp=fe5d005a9a922a4a15427e47c5d9e8e493926bc7;hb=8e01353ea837db6f80a154fafe9dea697ce03410;hpb=fc253e2fa06742656bd018981ec000799c956391 diff --git a/lib/bufio.c b/lib/bufio.c index fe5d005..1929d31 100644 --- a/lib/bufio.c +++ b/lib/bufio.c @@ -267,8 +267,14 @@ ssize_t biowritesome(struct bufio *bio, const void *data, size_t len) ret = min(len, bio->wbuf.s - bio->wbuf.d); memcpy(bio->wbuf.b + bio->wbuf.d, data, ret); bio->wbuf.d += ret; - if((bioflushsome(bio) < 0) && (ret == 0)) - return(-1); + if(bioflushsome(bio) < 0) { + if(ret == 0) + return(-1); + if(ret < bio->wbuf.d - bio->wh) { /* Should never be false */ + bio->wbuf.d -= ret; + return(-1); + } + } return(ret); }