mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:27:43 +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
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));
|
int nread = ::read(m_fd, read_buffer, sizeof(read_buffer));
|
||||||
if (nread < 0) {
|
if (nread < 0) {
|
||||||
set_error(errno);
|
set_error(errno);
|
||||||
return ByteBuffer::copy(data.data(), data.size());
|
break;
|
||||||
}
|
}
|
||||||
if (nread == 0) {
|
if (nread == 0) {
|
||||||
set_eof(true);
|
set_eof(true);
|
||||||
|
@ -135,6 +135,8 @@ ByteBuffer CIODevice::read_all()
|
||||||
}
|
}
|
||||||
data.append((const u8*)read_buffer, nread);
|
data.append((const u8*)read_buffer, nread);
|
||||||
}
|
}
|
||||||
|
if (data.is_empty())
|
||||||
|
return {};
|
||||||
return ByteBuffer::copy(data.data(), data.size());
|
return ByteBuffer::copy(data.data(), data.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue