1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

TextEditor: Avoid some potential nullptr dereferences in the Iterator class

This commit is contained in:
ed 2021-08-13 16:29:22 +01:00
parent 80602649a2
commit c3cb59d6ae

View file

@ -480,6 +480,9 @@ struct TextEditor::Iterator
//==============================================================================
void draw (Graphics& g, const UniformTextSection*& lastSection, AffineTransform transform) const
{
if (atom == nullptr)
return;
if (passwordCharacter != 0 || (underlineWhitespace || ! atom->isWhitespace()))
{
if (lastSection != currentSection)
@ -513,6 +516,9 @@ struct TextEditor::Iterator
void drawSelectedText (Graphics& g, Range<int> selected, Colour selectedTextColour, AffineTransform transform) const
{
if (atom == nullptr)
return;
if (passwordCharacter != 0 || ! atom->isWhitespace())
{
GlyphArrangement ga;
@ -548,7 +554,7 @@ struct TextEditor::Iterator
//==============================================================================
float indexToX (int indexToFind) const
{
if (indexToFind <= indexInText)
if (indexToFind <= indexInText || atom == nullptr)
return atomX;
if (indexToFind >= indexInText + atom->numChars)
@ -567,7 +573,7 @@ struct TextEditor::Iterator
int xToIndex (float xToFind) const
{
if (xToFind <= atomX || atom->isNewLine())
if (xToFind <= atomX || atom == nullptr || atom->isNewLine())
return indexInText;
if (xToFind >= atomRight)