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:
parent
c8d8201aba
commit
49c82b6ca3
1 changed files with 9 additions and 4 deletions
|
|
@ -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!
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue