1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:17:44 +00:00

LibProtocol: Fix crash on EOF when using Request::stream_into

`Request::stream_into_impl` would call `stream.write_or_error` with a
zero length buffer when EOF was reached. However, the
`Core::Stream::Stream::write_or_error` implementation verifies that the
buffer lenght is non-zero, resulting in a crash. With this change the
zero length buffer is never written to the stream.
This commit is contained in:
Michiel Visser 2022-02-16 11:51:04 +01:00 committed by Ali Mohammad Pur
parent 7070713ec8
commit 45004022ad

View file

@ -52,12 +52,12 @@ void Request::stream_into_impl(T& stream)
if (result.is_error())
continue;
auto nread = result.value();
if (nread == 0)
break;
if (!stream.write_or_error({ buf, nread })) {
// FIXME: What do we do here?
TODO();
}
if (nread == 0)
break;
} while (true);
if (m_internal_stream_data->read_stream->is_eof() && m_internal_stream_data->request_done) {