Allow the dispatcher in DescriptorPool to be set to nullptr.

Previously, when we call SetRecursiveBuildDispatcher(nullptr), this created a unique_ptr to an AnyInvocable object with a function pointer to a nullptr, which triggers a segmentation fault inside BuildFile.

PiperOrigin-RevId: 607435995
pull/15855/head
Protobuf Team Bot 9 months ago committed by Copybara-Service
parent 5553de265e
commit 783a023f6a
  1. 10
      src/google/protobuf/descriptor.h

@ -2237,9 +2237,13 @@ class PROTOBUF_EXPORT DescriptorPool {
// Asynchronous execution is undefined behavior.
void SetRecursiveBuildDispatcher(
absl::AnyInvocable<void(absl::FunctionRef<void()>) const> dispatcher) {
dispatcher_ = std::make_unique<
absl::AnyInvocable<void(absl::FunctionRef<void()>) const>>(
std::move(dispatcher));
if (dispatcher != nullptr) {
dispatcher_ = std::make_unique<
absl::AnyInvocable<void(absl::FunctionRef<void()>) const>>(
std::move(dispatcher));
} else {
dispatcher_.reset(nullptr);
}
}
#endif // SWIG

Loading…
Cancel
Save