Clarify that the input to proto2::DynamicMessageFactory::GetPrototype should be non-null

PiperOrigin-RevId: 631938646
pull/16778/head
Protobuf Team Bot 11 months ago committed by Copybara-Service
parent ec126a5069
commit b694cfa441
  1. 1
      src/google/protobuf/dynamic_message.cc
  2. 4
      src/google/protobuf/dynamic_message.h

@ -620,6 +620,7 @@ DynamicMessageFactory::~DynamicMessageFactory() {
} }
const Message* DynamicMessageFactory::GetPrototype(const Descriptor* type) { const Message* DynamicMessageFactory::GetPrototype(const Descriptor* type) {
ABSL_CHECK(type != nullptr);
absl::MutexLock lock(&prototypes_mutex_); absl::MutexLock lock(&prototypes_mutex_);
return GetPrototypeNoLock(type); return GetPrototypeNoLock(type);
} }

@ -108,8 +108,8 @@ class PROTOBUF_EXPORT DynamicMessageFactory : public MessageFactory {
// prototype, so these must be destroyed before the DynamicMessageFactory // prototype, so these must be destroyed before the DynamicMessageFactory
// is destroyed. // is destroyed.
// //
// The given descriptor must outlive the returned message, and hence must // The given descriptor must be non-null and outlive the returned message, and
// outlive the DynamicMessageFactory. // hence must outlive the DynamicMessageFactory.
// //
// The method is thread-safe. // The method is thread-safe.
const Message* GetPrototype(const Descriptor* type) override; const Message* GetPrototype(const Descriptor* type) override;

Loading…
Cancel
Save