diff --git a/userspace/libraries/LibC/stdio.cpp b/userspace/libraries/LibC/stdio.cpp index 43709a13..567f745e 100644 --- a/userspace/libraries/LibC/stdio.cpp +++ b/userspace/libraries/LibC/stdio.cpp @@ -908,12 +908,16 @@ void setbuf(FILE* file, char* buffer) int setvbuf(FILE* file, char* buffer, int type, size_t size) { + ScopeLock _(file); + if (file->fd == -1) { errno = EBADF; return -1; } + (void)fflush(file); + if (size == 0) type = _IONBF;