mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03: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
@ -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 New Issue
Block a user