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
This commit is contained in:
parent
779434378e
commit
1bf3b4a06d
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user