aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar temporal <temporal@630680e5-0e50-0410-840e-4b1c322b438d>2009-04-28 08:09:44 +0000
committerGravatar temporal <temporal@630680e5-0e50-0410-840e-4b1c322b438d>2009-04-28 08:09:44 +0000
commit1589b1d8c17de216eb96c67cadf8a676e229bafc (patch)
tree747c1d15904087e3d8b139ab07b5ca0ea839a160
parentc5ff06cc74e03e6846218b750b99c77d72a39a75 (diff)
Fix startup crash when statically linking on Mac.
-rw-r--r--src/google/protobuf/descriptor_database.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/google/protobuf/descriptor_database.cc b/src/google/protobuf/descriptor_database.cc
index 910f7e4e..6ea674d1 100644
--- a/src/google/protobuf/descriptor_database.cc
+++ b/src/google/protobuf/descriptor_database.cc
@@ -57,7 +57,10 @@ bool SimpleDescriptorDatabase::DescriptorIndex<Value>::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++) {