We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d7ecd5e commit 63f4021Copy full SHA for 63f4021
hardware/arduino/cores/arduino/WString.cpp
@@ -150,14 +150,16 @@ const String & String::operator+=( const String &other )
150
_length += other._length;
151
if ( _length > _capacity )
152
{
153
- char *temp = _buffer;
154
- getBuffer( _length );
155
- if ( _buffer != NULL )
156
- strcpy( _buffer, temp );
157
- free(temp);
+ char *temp = (char *)realloc(_buffer, _length + 1);
+ if ( temp != NULL ) {
+ _buffer = temp;
+ _capacity = _length;
+ } else {
158
+ _length -= other._length;
159
+ return *this;
160
+ }
161
}
- strcat( _buffer, other._buffer );
162
+ strcat( _buffer, other._buffer );
163
return *this;
164
165
0 commit comments