diff options
author | Todd Poynor <toddpoynor@google.com> | 2013-05-02 15:41:35 -0700 |
---|---|---|
committer | Todd Poynor <toddpoynor@google.com> | 2013-05-07 12:09:46 -0700 |
commit | 1bf3b4a06d92e728b9e32d560b54cb41a562dde0 (patch) | |
tree | c128769527def182bd445301747de870a75bc52c /libs/utils | |
parent | 779434378ee7ca43800a7c7d949c1433c39736fc (diff) | |
download | frameworks_native-1bf3b4a06d92e728b9e32d560b54cb41a562dde0.zip frameworks_native-1bf3b4a06d92e728b9e32d560b54cb41a562dde0.tar.gz frameworks_native-1bf3b4a06d92e728b9e32d560b54cb41a562dde0.tar.bz2 |
String8: ensure static init done prior to empty string reference
Avoid NULL deref on static initialization of empty String8 objects prior
to libutils static init.
Change-Id: I3d420041ba62b97ed8c2dfd2532a2dcd72b84ff1
Diffstat (limited to 'libs/utils')
-rw-r--r-- | libs/utils/String8.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/libs/utils/String8.cpp b/libs/utils/String8.cpp index 562f026..75daee9 100644 --- a/libs/utils/String8.cpp +++ b/libs/utils/String8.cpp @@ -48,12 +48,16 @@ int gDarwinIsReallyAnnoying; static inline char* getEmptyString() { + if (!gEmptyStringBuf) initialize_string8(); + gEmptyStringBuf->acquire(); return gEmptyString; } void initialize_string8() { + if (gEmptyStringBuf) return; + // HACK: This dummy dependency forces linking libutils Static.cpp, // which is needed to initialize String8/String16 classes. // These variables are named for Darwin, but are needed elsewhere too, |