mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 01:20:25 +00:00
CIODevice: read_all() should return a null ByteBuffer when nothing read
We were returning a zero-length ByteBuffer in some cases. We should be consistent about this and always return a null ByteBuffer if nothing was read at all.
This commit is contained in:
parent
825fa3463c
commit
b305a51c90
Notes:
sideshowbarker
2024-07-19 12:09:40 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/b305a51c90d
1 changed files with 3 additions and 1 deletions
|
@ -127,7 +127,7 @@ ByteBuffer CIODevice::read_all()
|
|||
int nread = ::read(m_fd, read_buffer, sizeof(read_buffer));
|
||||
if (nread < 0) {
|
||||
set_error(errno);
|
||||
return ByteBuffer::copy(data.data(), data.size());
|
||||
break;
|
||||
}
|
||||
if (nread == 0) {
|
||||
set_eof(true);
|
||||
|
@ -135,6 +135,8 @@ ByteBuffer CIODevice::read_all()
|
|||
}
|
||||
data.append((const u8*)read_buffer, nread);
|
||||
}
|
||||
if (data.is_empty())
|
||||
return {};
|
||||
return ByteBuffer::copy(data.data(), data.size());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue