LibC: Make sure FILE's buffer does not get overflown
This commit is contained in:
parent
c6946d0145
commit
32afa33a06
|
@ -779,11 +779,17 @@ int putc_unlocked(int c, FILE* file)
|
|||
return (unsigned char)c;
|
||||
}
|
||||
|
||||
if (file->buffer_idx >= file->buffer_size)
|
||||
if (fflush(file) == EOF)
|
||||
return EOF;
|
||||
|
||||
file->buffer[file->buffer_idx] = c;
|
||||
file->buffer_idx++;
|
||||
|
||||
if ((file->buffer_type == _IOLBF && c == '\n') || file->buffer_idx >= file->buffer_size)
|
||||
if (fflush(file) == EOF)
|
||||
return EOF;
|
||||
|
||||
return (unsigned char)c;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue