pull/35566/head
Esun Kim 1 year ago
parent 826ed20819
commit 02635228f5
  1. 7
      include/grpcpp/support/proto_buffer_reader.h

@ -150,6 +150,9 @@ class ProtoBufferReader : public grpc::protobuf::io::ZeroCopyInputStream {
}
int64_t take = (std::min)(backup_count(), static_cast<int64_t>(count));
set_backup_count(backup_count() - take);
// This cast is safe as the size of a serialized protobuf message
// should be smaller than 2GiB.
// (https://protobuf.dev/programming-guides/encoding/#size-limit)
count -= static_cast<int>(take);
if (count == 0) {
return true;
@ -163,9 +166,7 @@ class ProtoBufferReader : public grpc::protobuf::io::ZeroCopyInputStream {
set_byte_count(ByteCount() + slice_length);
if (slice_length <= static_cast<uint64_t>(count)) {
cord->Append(MakeCordFromSlice(grpc_slice_ref(*slice())));
// This cast is safe as the size of a serialized protobuf message
// should be smaller than 2GiB.
// (https://protobuf.dev/programming-guides/encoding/#size-limit)
// This cast is safe as above.
count -= static_cast<int>(slice_length);
} else {
cord->Append(MakeCordFromSlice(grpc_slice_split_head(slice(), count)));

Loading…
Cancel
Save