diff options
-rw-r--r-- | include/grpc++/impl/rpc_service_method.h | 6 | ||||
-rw-r--r-- | src/cpp/proto/proto_utils.cc | 8 |
2 files changed, 11 insertions, 3 deletions
diff --git a/include/grpc++/impl/rpc_service_method.h b/include/grpc++/impl/rpc_service_method.h index fcb0b7ccce..9d30d9627c 100644 --- a/include/grpc++/impl/rpc_service_method.h +++ b/include/grpc++/impl/rpc_service_method.h @@ -251,7 +251,11 @@ class RpcService { void AddMethod(RpcServiceMethod* method) { methods_.emplace_back(method); } RpcServiceMethod* GetMethod(int i) { return methods_[i].get(); } - int GetMethodCount() const { return methods_.size(); } + int GetMethodCount() const { + // On win x64, int is only 32bit + GPR_ASSERT(methods_.size() <= INT_MAX); + return (int)methods_.size(); + } private: std::vector<std::unique_ptr<RpcServiceMethod>> methods_; diff --git a/src/cpp/proto/proto_utils.cc b/src/cpp/proto/proto_utils.cc index b1330fde7f..0a05f29222 100644 --- a/src/cpp/proto/proto_utils.cc +++ b/src/cpp/proto/proto_utils.cc @@ -70,7 +70,9 @@ class GrpcBufferWriter GRPC_FINAL slice_ = gpr_slice_malloc(block_size_); } *data = GPR_SLICE_START_PTR(slice_); - byte_count_ += * size = GPR_SLICE_LENGTH(slice_); + // On win x64, int is only 32bit + GPR_ASSERT(GPR_SLICE_LENGTH(slice_) <= INT_MAX); + byte_count_ += * size = (int)GPR_SLICE_LENGTH(slice_); gpr_slice_buffer_add(slice_buffer_, slice_); return true; } @@ -124,7 +126,9 @@ class GrpcBufferReader GRPC_FINAL } gpr_slice_unref(slice_); *data = GPR_SLICE_START_PTR(slice_); - byte_count_ += * size = GPR_SLICE_LENGTH(slice_); + // On win x64, int is only 32bit + GPR_ASSERT(GPR_SLICE_LENGTH(slice_) <= INT_MAX); + byte_count_ += * size = (int)GPR_SLICE_LENGTH(slice_); return true; } |