diff --git a/src/google/protobuf/wire_format.cc b/src/google/protobuf/wire_format.cc index 0821928243..72e13c4ba7 100644 --- a/src/google/protobuf/wire_format.cc +++ b/src/google/protobuf/wire_format.cc @@ -1758,8 +1758,9 @@ size_t WireFormat::MessageSetItemByteSize(const FieldDescriptor* field, our_size += io::CodedOutputStream::VarintSize32(field->number()); // message - const Message& sub_message = message_reflection->GetMessage(message, field); - size_t message_size = sub_message.ByteSizeLong(); + size_t message_size; + const Message& sub_message = message_reflection->GetMessage(message, field); + message_size = sub_message.ByteSizeLong(); our_size += io::CodedOutputStream::VarintSize32(message_size); our_size += message_size; diff --git a/src/google/protobuf/wire_format_unittest.inc b/src/google/protobuf/wire_format_unittest.inc index 6347a6a87b..afd2f1e2fc 100644 --- a/src/google/protobuf/wire_format_unittest.inc +++ b/src/google/protobuf/wire_format_unittest.inc @@ -26,6 +26,7 @@ #include "absl/strings/match.h" #include "google/protobuf/descriptor.h" #include "google/protobuf/dynamic_message.h" +#include "google/protobuf/generated_message_tctable_impl.h" #include "google/protobuf/io/coded_stream.h" #include "google/protobuf/io/zero_copy_stream_impl.h" #include "google/protobuf/io/zero_copy_stream_impl_lite.h"