fix(replication): Handle errors instead of crashing. (#1757)

This commit is contained in:
Roy Jacobson 2023-08-29 15:29:40 +03:00 committed by GitHub
parent d964325f93
commit 254c86786e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View file

@ -106,7 +106,11 @@ std::error_code JournalReader::EnsureRead(size_t num) {
// Try reading at least how much we need, but possibly more
uint64_t read;
SET_OR_RETURN(source_->ReadAtLeast(buf_.AppendBuffer(), remainder), read);
CHECK(read >= remainder);
// Happens on end of stream (for example, a too-small string buffer or a closed socket)
if (read < remainder) {
return make_error_code(errc::io_error);
}
buf_.CommitWrite(read);
return {};