aboutsummaryrefslogtreecommitdiff
path: root/src/google/protobuf/descriptor.cc
diff options
context:
space:
mode:
authortemporal <temporal@630680e5-0e50-0410-840e-4b1c322b438d>2008-07-25 04:38:05 +0000
committertemporal <temporal@630680e5-0e50-0410-840e-4b1c322b438d>2008-07-25 04:38:05 +0000
commit6fdb0964e3a9873d1eb08b28634c74bd082326ac (patch)
treef9228c435c5f8d8cc8504653046af2e347c36d49 /src/google/protobuf/descriptor.cc
parentf206351d1469970230caa5f61eaa54797194bee1 (diff)
downloadprotobuf-6fdb0964e3a9873d1eb08b28634c74bd082326ac.tar.gz
protobuf-6fdb0964e3a9873d1eb08b28634c74bd082326ac.tar.bz2
protobuf-6fdb0964e3a9873d1eb08b28634c74bd082326ac.zip
Fix static initialization ordering bug that caused crashes at startup when
compiling on Mac with static linking.
Diffstat (limited to 'src/google/protobuf/descriptor.cc')
-rw-r--r--src/google/protobuf/descriptor.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/google/protobuf/descriptor.cc b/src/google/protobuf/descriptor.cc
index 48db0cc2..4485fd43 100644
--- a/src/google/protobuf/descriptor.cc
+++ b/src/google/protobuf/descriptor.cc
@@ -2065,7 +2065,15 @@ const FileDescriptor* DescriptorBuilder::BuildFile(
}
result->name_ = tables_->AllocateString(proto.name());
- result->package_ = tables_->AllocateString(proto.package());
+ if (proto.has_package()) {
+ result->package_ = tables_->AllocateString(proto.package());
+ } else {
+ // We cannot rely on proto.package() returning a valid string if
+ // proto.has_package() is false, because we might be running at static
+ // initialization time, in which case default values have not yet been
+ // initialized.
+ result->package_ = tables_->AllocateString("");
+ }
result->pool_ = pool_;
// Add to tables.