1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 09:38:11 +00:00

Oops, StringImpl's "the empty string" global was not always initialized.

These "oops forgot to initialize" bugs are getting annoying...
This commit is contained in:
Andreas Kling 2018-10-22 13:10:08 +02:00
parent c5e55f4737
commit 702d308e67
3 changed files with 14 additions and 7 deletions

View file

@ -4,12 +4,17 @@
namespace AK {
static StringImpl* s_theEmptyStringImpl = nullptr;
void StringImpl::initializeGlobals()
{
s_theEmptyStringImpl = new StringImpl(ConstructTheEmptyStringImpl);;
}
StringImpl& StringImpl::theEmptyStringImpl()
{
static StringImpl* s = nullptr;
if (!s)
s = new StringImpl(ConstructTheEmptyStringImpl);
return *s;
ASSERT(s_theEmptyStringImpl);
return *s_theEmptyStringImpl;
}
StringImpl::~StringImpl()