diff --git a/src/google/protobuf/descriptor_database.cc b/src/google/protobuf/descriptor_database.cc index 910f7e4edf..6ea674d170 100644 --- a/src/google/protobuf/descriptor_database.cc +++ b/src/google/protobuf/descriptor_database.cc @@ -57,7 +57,10 @@ bool SimpleDescriptorDatabase::DescriptorIndex::AddFile( return false; } - string path = file.package(); + // We must be careful here -- calling file.package() if file.has_package() is + // false could access an uninitialized static-storage variable if we are being + // run at startup time. + string path = file.has_package() ? file.package() : string(); if (!path.empty()) path += '.'; for (int i = 0; i < file.message_type_size(); i++) {