You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The ESP8266 Arduino port just discovered the following line in String::remove where strncpy is used with overlapping source and destination addresses (it's moving things backwards in the allocated buffer). See link for the valgrind warnings reported by our CI system.
While it's true that on the AVR, an 8-bit MCU, str*cpy will be implemented in a byte-wise manner, this code has and will probably be copied to 16- and 32-bit systems where they may use optimizations which give strange results occasionally due to the overlap. A simple replacement of the strcpy with a memmove in this line clears this error and provides desired behavior on all systems.
The text was updated successfully, but these errors were encountered:
earlephilhower
changed the title
String class ::remove has overlapping strncpy, undefined results per standard specs
String ::remove, ::trim have overlapping strncpy/memcpy, undefined results per standard specs
Jul 18, 2018
The ESP8266 Arduino port just discovered the following line in
String::remove
wherestrncpy
is used with overlapping source and destination addresses (it's moving things backwards in the allocated buffer). See link for the valgrind warnings reported by our CI system.ArduinoCore-avr/cores/arduino/WString.cpp
Lines 697 to 699 in b7c6076
str*cpy
is undefined when you overlap source and destinationWhile it's true that on the AVR, an 8-bit MCU, str*cpy will be implemented in a byte-wise manner, this code has and will probably be copied to 16- and 32-bit systems where they may use optimizations which give strange results occasionally due to the overlap. A simple replacement of the
strcpy
with amemmove
in this line clears this error and provides desired behavior on all systems.The text was updated successfully, but these errors were encountered: