Skip to content

Commit

Permalink
LibCore: Allow reads smaller than the buffered data size in IODevice
Browse files Browse the repository at this point in the history
This restriction doesn't make much sense, a user should be free to
consume the buffered data with as small a max_size as they desire.
This fixes a possible RequestServer spin when talking to HTTP servers.
  • Loading branch information
alimpfard authored and awesomekling committed Oct 4, 2021
1 parent 7ee3432 commit e112e66
Showing 1 changed file with 0 additions and 9 deletions.
9 changes: 0 additions & 9 deletions Userland/Libraries/LibCore/IODevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,6 @@ ByteBuffer IODevice::read(size_t max_size)
if (m_buffered_data.size() < max_size)
populate_read_buffer(max(max_size - m_buffered_data.size(), 1024));

if (m_buffered_data.size() > max_size) {
if (m_error)
return {};
if (m_eof) {
dbgln("IODevice::read: At EOF but there's more than max_size({}) buffered", max_size);
return {};
}
}

auto size = min(max_size, m_buffered_data.size());
auto buffer_result = ByteBuffer::create_uninitialized(size);
if (!buffer_result.has_value()) {
Expand Down

0 comments on commit e112e66

Please sign in to comment.