LibC: fflush file in setvbuf before updating the buffer

This commit is contained in:
Bananymous 2025-07-02 00:55:04 +03:00
parent 8e0d79f301
commit 8aff315c7b
1 changed files with 4 additions and 0 deletions

View File

@ -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;