]> git.dolda2000.com Git - ashd.git/commitdiff
lib: Fixed bioprintf bug.
authorFredrik Tolf <fredrik@dolda2000.com>
Sun, 30 Oct 2016 20:08:26 +0000 (21:08 +0100)
committerFredrik Tolf <fredrik@dolda2000.com>
Sun, 30 Oct 2016 20:08:32 +0000 (21:08 +0100)
lib/bufio.c

index c08e9dd9a96f18ec2c1c974ec37697f597580e75..11d8c04252d373d4f2df8604e82adfeedc20722b 100644 (file)
@@ -289,11 +289,11 @@ int bioprintf(struct bufio *bio, const char *format, ...)
        va_start(args, format);
        ret = vsnprintf(bio->wbuf.b + bio->wbuf.d, bio->wbuf.s - bio->wbuf.d, format, args);
        va_end(args);
-       if(ret <= bio->wbuf.s - bio->wbuf.d) {
+       if(ret < bio->wbuf.s - bio->wbuf.d) {
            bio->wbuf.d += ret;
            return(0);
        }
-       if(biowensure(bio, ret) < 0)
+       if(biowensure(bio, ret + 1) < 0)
            return(-1);
     }
 }