From bec4585d3dd5f9a10424304752adc09919d0564b Mon Sep 17 00:00:00 2001 From: Mike Kruskal Date: Fri, 19 May 2023 21:24:28 -0700 Subject: [PATCH] Internal changes PiperOrigin-RevId: 533624998 --- .../protobuf/compiler/command_line_interface.cc | 17 ++++++++++------- .../compiler/command_line_interface_unittest.cc | 1 + 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc index d6eae5b16f..0f3c9c1949 100644 --- a/src/google/protobuf/compiler/command_line_interface.cc +++ b/src/google/protobuf/compiler/command_line_interface.cc @@ -1306,13 +1306,16 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) { // something like descriptor->file()->name(), but ExtensionRange does not // support this. for (const google::protobuf::FileDescriptor* file : parsed_files) { - google::protobuf::internal::VisitDescriptors(*file, [&](const auto& descriptor) { - if (!ValidateTargetConstraints(descriptor.options(), *descriptor_pool, - *error_collector, file->name(), - GetTargetType(&descriptor))) { - validation_error = true; - } - }); + FileDescriptorProto proto; + file->CopyTo(&proto); + google::protobuf::internal::VisitDescriptors( + *file, proto, [&](const auto& descriptor, const auto& proto) { + if (!ValidateTargetConstraints(proto.options(), *descriptor_pool, + *error_collector, file->name(), + GetTargetType(&descriptor))) { + validation_error = true; + } + }); } diff --git a/src/google/protobuf/compiler/command_line_interface_unittest.cc b/src/google/protobuf/compiler/command_line_interface_unittest.cc index a753775728..6c0d1cfd12 100644 --- a/src/google/protobuf/compiler/command_line_interface_unittest.cc +++ b/src/google/protobuf/compiler/command_line_interface_unittest.cc @@ -1419,6 +1419,7 @@ TEST_F(CommandLineInterfaceTest, AllowServicesHasService) { } + TEST_F(CommandLineInterfaceTest, DirectDependencies_Missing_EmptyList) { CreateTempFile("foo.proto", "syntax = \"proto2\";\n"