1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-11 23:54:18 +00:00

Made the check for empty Strings more robust to fix a symbol collision crash

This commit is contained in:
ed 2019-07-10 11:33:23 +01:00
parent c8d8201aba
commit 49c82b6ca3

View file

@ -56,7 +56,7 @@ struct EmptyString
String::CharPointerType::CharType text;
};
static const EmptyString emptyString = { 0x3fffffff, sizeof (String::CharPointerType::CharType), 0 };
static const EmptyString emptyString { 0x3fffffff, sizeof (String::CharPointerType::CharType), 0 };
//==============================================================================
class StringHolder
@ -156,13 +156,13 @@ public:
{
auto* b = bufferFromText (text);
if (b != (StringHolder*) &emptyString)
if (! isEmptyString (b))
++(b->refCount);
}
static inline void release (StringHolder* const b) noexcept
{
if (b != (StringHolder*) &emptyString)
if (! isEmptyString (b))
if (--(b->refCount) == -1)
delete[] reinterpret_cast<char*> (b);
}
@ -182,7 +182,7 @@ public:
{
auto* b = bufferFromText (text);
if (b == (StringHolder*) &emptyString)
if (isEmptyString (b))
{
auto newText = createUninitialisedBytes (numBytes);
newText.writeNull();
@ -217,6 +217,11 @@ private:
- (reinterpret_cast<size_t> (reinterpret_cast<StringHolder*> (128)->text) - 128));
}
static inline bool isEmptyString (StringHolder* other)
{
return (other->refCount.get() & 0x30000000) != 0;
}
void compileTimeChecks()
{
// Let me know if any of these assertions fail on your system!