libc: Reset the read buffer even when read() returns an error
This fixes the same data being read multiple times if an error was returned
This commit is contained in:
parent
7c254e5e15
commit
198935eb30
@ -135,6 +135,8 @@ static ssize_t read_data_into_buffer(FILE* stream)
|
||||
stream->_buf.index = 0;
|
||||
ssize_t nread = read(stream->_fd, stream->_buf.buffer, stream->_buf.capacity);
|
||||
if (nread >= 0) stream->_buf.size = nread;
|
||||
else
|
||||
stream->_buf.size = 0;
|
||||
stream->_buf.status |= FileStatusFlags::LastRead;
|
||||
return nread;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user