diff --git a/src/google/protobuf/compiler/cpp/cpp_file.cc b/src/google/protobuf/compiler/cpp/cpp_file.cc index 83e68c1265..e0542ae86d 100644 --- a/src/google/protobuf/compiler/cpp/cpp_file.cc +++ b/src/google/protobuf/compiler/cpp/cpp_file.cc @@ -751,6 +751,15 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { message_generators_[i]->GenerateShutdownCode(printer); } + if (HasDescriptorMethods(file_, options_)) { + for (int i = 0; i < message_generators_.size(); i++) { + if (!IsMapEntryMessage(message_generators_[i]->descriptor_)) continue; + printer->Print( + "delete file_level_metadata[$index$].reflection;\n", + "index", SimpleItoa(i)); + } + } + printer->Outdent(); printer->Print( "}\n\n"); diff --git a/src/google/protobuf/struct.pb.cc b/src/google/protobuf/struct.pb.cc index 825810b124..207e9efed7 100644 --- a/src/google/protobuf/struct.pb.cc +++ b/src/google/protobuf/struct.pb.cc @@ -133,6 +133,7 @@ void TableStruct::Shutdown() { delete file_level_metadata[2].reflection; _ListValue_default_instance_.Shutdown(); delete file_level_metadata[3].reflection; + delete file_level_metadata[0].reflection; } void TableStruct::InitDefaultsImpl() {