James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame^] | 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
| 2 | From: Peter Johnson <johnson.peter@gmail.com> |
| 3 | Date: Sat, 10 Jun 2023 15:03:38 -0700 |
| 4 | Subject: [PATCH 04/11] Fix coded_stream WriteRaw |
| 5 | |
| 6 | --- |
| 7 | src/google/protobuf/implicit_weak_message.h | 2 +- |
| 8 | src/google/protobuf/io/coded_stream.h | 4 ++-- |
| 9 | 2 files changed, 3 insertions(+), 3 deletions(-) |
| 10 | |
| 11 | diff --git a/src/google/protobuf/implicit_weak_message.h b/src/google/protobuf/implicit_weak_message.h |
| 12 | index b894ab4809090011f381828857d1674a6b7bff9b..c358c14c06f773d87f5089c75566a5a6fcba13e6 100644 |
| 13 | --- a/src/google/protobuf/implicit_weak_message.h |
| 14 | +++ b/src/google/protobuf/implicit_weak_message.h |
| 15 | @@ -100,7 +100,7 @@ class PROTOBUF_EXPORT ImplicitWeakMessage : public MessageLite { |
| 16 | if (data_ == nullptr) { |
| 17 | return target; |
| 18 | } |
| 19 | - return stream->WriteRaw(data_->data(), static_cast<int>(data_->size()), |
| 20 | + return stream->WriteRaw(data_->data(), data_->size(), |
| 21 | target); |
| 22 | } |
| 23 | |
| 24 | diff --git a/src/google/protobuf/io/coded_stream.h b/src/google/protobuf/io/coded_stream.h |
| 25 | index c8fc994f916d047c0a7b176e53c9e946ebd752de..6c0dd4ab4099d1d748957af8bfc5f8c59c2aa3d6 100644 |
| 26 | --- a/src/google/protobuf/io/coded_stream.h |
| 27 | +++ b/src/google/protobuf/io/coded_stream.h |
| 28 | @@ -677,8 +677,8 @@ class PROTOBUF_EXPORT EpsCopyOutputStream { |
| 29 | return ptr; |
| 30 | } |
| 31 | |
| 32 | - uint8_t* WriteRaw(const void* data, int size, uint8_t* ptr) { |
| 33 | - if (PROTOBUF_PREDICT_FALSE(end_ - ptr < size)) { |
| 34 | + uint8_t* WriteRaw(const void* data, size_t size, uint8_t* ptr) { |
| 35 | + if (PROTOBUF_PREDICT_FALSE(end_ - ptr < static_cast<int>(size))) { |
| 36 | return WriteRawFallback(data, size, ptr); |
| 37 | } |
| 38 | std::memcpy(ptr, data, size); |