X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fstdio%2Fsetvbuf.c;h=523dddc8ba28f53a7b3fcc4e3e5323de092acc22;hb=dec8f0a4fa7aa533c843e6eaec862be674ff3a1a;hp=b6b9b018d6510b7a47975a2f6b7d5bb93c7a19d3;hpb=3f3cc3e99558501318e2f16ff03bbd68ce5a5e95;p=musl diff --git a/src/stdio/setvbuf.c b/src/stdio/setvbuf.c index b6b9b018..523dddc8 100644 --- a/src/stdio/setvbuf.c +++ b/src/stdio/setvbuf.c @@ -12,13 +12,15 @@ int setvbuf(FILE *restrict f, char *restrict buf, int type, size_t size) if (type == _IONBF) { f->buf_size = 0; - } else { + } else if (type == _IOLBF || type == _IOFBF) { if (buf && size >= UNGET) { - f->buf = (void *)buf; + f->buf = (void *)(buf + UNGET); f->buf_size = size - UNGET; } if (type == _IOLBF && f->buf_size) f->lbf = '\n'; + } else { + return -1; } f->flags |= F_SVB;