diff --git a/src/google/protobuf/generated_message_reflection.cc b/src/google/protobuf/generated_message_reflection.cc index 5c7a86d4ac92..d1f8ba53ce02 100644 --- a/src/google/protobuf/generated_message_reflection.cc +++ b/src/google/protobuf/generated_message_reflection.cc @@ -2591,6 +2591,7 @@ void* Reflection::MutableRawRepeatedField(Message* message, const Descriptor* desc) const { (void)ctype; // Parameter is used by Google-internal code. USAGE_CHECK_REPEATED("MutableRawRepeatedField"); + USAGE_CHECK_MESSAGE_TYPE(MutableRawRepeatedField); if (field->cpp_type() != cpptype && (field->cpp_type() != FieldDescriptor::CPPTYPE_ENUM || @@ -2618,6 +2619,7 @@ const void* Reflection::GetRawRepeatedField(const Message& message, int ctype, const Descriptor* desc) const { USAGE_CHECK_REPEATED("GetRawRepeatedField"); + USAGE_CHECK_MESSAGE_TYPE(GetRawRepeatedField); if (field->cpp_type() != cpptype && (field->cpp_type() != FieldDescriptor::CPPTYPE_ENUM || cpptype != FieldDescriptor::CPPTYPE_INT32)) diff --git a/src/google/protobuf/message.h b/src/google/protobuf/message.h index fb4fa3a63a78..3527ce203915 100644 --- a/src/google/protobuf/message.h +++ b/src/google/protobuf/message.h @@ -479,6 +479,7 @@ class PROTOBUF_EXPORT Reflection final { // Returns true if the given message is a default message instance. bool IsDefaultInstance(const Message& message) const { + ABSL_DCHECK_EQ(message.GetReflection(), this); return schema_.IsDefaultInstance(message); }