mirror of
https://github.com/arduino/Arduino.git
synced 2025-03-15 12:29:26 +01:00
Returning a reference to a dummy character for indices beyond the string length (in operator[]).
This commit is contained in:
parent
e3856766c6
commit
f8077a96d7
@ -194,7 +194,11 @@ int String::operator>=( const String & rhs ) const
|
|||||||
|
|
||||||
char & String::operator[]( unsigned int index )
|
char & String::operator[]( unsigned int index )
|
||||||
{
|
{
|
||||||
// need to check for valid index, to do later
|
static char dummy_writable_char;
|
||||||
|
if (index >= _length || !_buffer) {
|
||||||
|
dummy_writable_char = 0;
|
||||||
|
return dummy_writable_char;
|
||||||
|
}
|
||||||
return _buffer[ index ];
|
return _buffer[ index ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user