From b694cfa4414c817ab12b7e593044ff92572c2e63 Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Wed, 8 May 2024 15:10:51 -0700 Subject: [PATCH] Clarify that the input to proto2::DynamicMessageFactory::GetPrototype should be non-null PiperOrigin-RevId: 631938646 --- src/google/protobuf/dynamic_message.cc | 1 + src/google/protobuf/dynamic_message.h | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/google/protobuf/dynamic_message.cc b/src/google/protobuf/dynamic_message.cc index 7927107815..c4448d51a0 100644 --- a/src/google/protobuf/dynamic_message.cc +++ b/src/google/protobuf/dynamic_message.cc @@ -620,6 +620,7 @@ DynamicMessageFactory::~DynamicMessageFactory() { } const Message* DynamicMessageFactory::GetPrototype(const Descriptor* type) { + ABSL_CHECK(type != nullptr); absl::MutexLock lock(&prototypes_mutex_); return GetPrototypeNoLock(type); } diff --git a/src/google/protobuf/dynamic_message.h b/src/google/protobuf/dynamic_message.h index 8d53e28cbc..0af9d441b5 100644 --- a/src/google/protobuf/dynamic_message.h +++ b/src/google/protobuf/dynamic_message.h @@ -108,8 +108,8 @@ class PROTOBUF_EXPORT DynamicMessageFactory : public MessageFactory { // prototype, so these must be destroyed before the DynamicMessageFactory // is destroyed. // - // The given descriptor must outlive the returned message, and hence must - // outlive the DynamicMessageFactory. + // The given descriptor must be non-null and outlive the returned message, and + // hence must outlive the DynamicMessageFactory. // // The method is thread-safe. const Message* GetPrototype(const Descriptor* type) override;