1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-03-13 10:29:35 +01:00

Returning a reference to a dummy character for indices beyond the string length (in operator[]).

This commit is contained in:
David A. Mellis 2010-08-28 09:55:26 +00:00
parent e3856766c6
commit f8077a96d7

View File

@ -194,7 +194,11 @@ int String::operator>=( const String & rhs ) const
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 ];
}