Make sure the generated pool is initialized before building any other pools.

Because we parse options into the generated pool for *all* descriptor pool builds, it's important that it's properly initialized.  Notably, if the C++ feature extensions haven't been registered we can end up with crashes from files that specify them.

PiperOrigin-RevId: 641043996
pull/17045/head
Mike Kruskal 6 months ago committed by Copybara-Service
parent 81c0ec381a
commit 851ca21f59
  1. 8
      src/google/protobuf/descriptor.cc

@ -5752,6 +5752,14 @@ static void PlanAllocationSize(const FileDescriptorProto& proto,
const FileDescriptor* DescriptorBuilder::BuildFile(
const FileDescriptorProto& proto) {
// Ensure the generated pool has been lazily initialized. This is most
// important for protos that use C++-specific features, since that extension
// is only registered lazily and we always parse options into the generated
// pool.
if (pool_ != DescriptorPool::internal_generated_pool()) {
DescriptorPool::generated_pool();
}
filename_ = proto.name();
// Check if the file already exists and is identical to the one being built.

Loading…
Cancel
Save