1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-16 00:34:19 +00:00

Jucer development. Small safety fix for String.

This commit is contained in:
Julian Storer 2010-04-16 16:29:05 +01:00
parent 0490668407
commit 643eea5fde
7 changed files with 183 additions and 87 deletions

View file

@ -1931,7 +1931,7 @@ const char* String::toUTF8() const
String* const mutableThis = const_cast <String*> (this);
mutableThis->text = StringHolder::makeUniqueWithSize (mutableThis->text, currentLen + 1 + utf8BytesNeeded / sizeof (juce_wchar));
char* const otherCopy = reinterpret_cast <char*> (text + currentLen);
char* const otherCopy = reinterpret_cast <char*> (mutableThis->text + currentLen);
copyToUTF8 (otherCopy, std::numeric_limits<int>::max());
return otherCopy;
@ -2123,7 +2123,7 @@ const char* String::toCString() const
String* const mutableThis = const_cast <String*> (this);
mutableThis->text = StringHolder::makeUniqueWithSize (mutableThis->text, (len + 1) * 2);
char* otherCopy = reinterpret_cast <char*> (text + len + 1);
char* otherCopy = reinterpret_cast <char*> (mutableThis->text + len + 1);
CharacterFunctions::copy (otherCopy, text, len);
otherCopy [len] = 0;
return otherCopy;