diff --git a/hardware/arduino/avr/cores/arduino/WString.cpp b/hardware/arduino/avr/cores/arduino/WString.cpp index f2572d60883..4ccfdb2416a 100644 --- a/hardware/arduino/avr/cores/arduino/WString.cpp +++ b/hardware/arduino/avr/cores/arduino/WString.cpp @@ -19,6 +19,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #include "WString.h" /*********************************************/ @@ -108,14 +110,14 @@ String::String(unsigned long value, unsigned char base) String::String(float value, unsigned char decimalPlaces) { init(); - char buf[33]; + char buf[FLT_MAX_10_EXP + 4 + decimalPlaces]; // +4, one for: 10, -, ., \0 *this = dtostrf(value, (decimalPlaces + 2), decimalPlaces, buf); } String::String(double value, unsigned char decimalPlaces) { init(); - char buf[33]; + char buf[DBL_MAX_10_EXP + 4 + decimalPlaces]; // +4, one for: 10, -, ., \0 *this = dtostrf(value, (decimalPlaces + 2), decimalPlaces, buf); } diff --git a/hardware/arduino/sam/cores/arduino/WString.cpp b/hardware/arduino/sam/cores/arduino/WString.cpp index 71bbc07d13b..65b117db281 100644 --- a/hardware/arduino/sam/cores/arduino/WString.cpp +++ b/hardware/arduino/sam/cores/arduino/WString.cpp @@ -19,6 +19,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #include "WString.h" #include "itoa.h" #include "avr/dtostrf.h" @@ -110,14 +112,14 @@ String::String(unsigned long value, unsigned char base) String::String(float value, unsigned char decimalPlaces) { init(); - char buf[33]; + char buf[FLT_MAX_10_EXP + 4 + decimalPlaces]; // +4, one for: 10, -, ., \0 *this = dtostrf(value, (decimalPlaces + 2), decimalPlaces, buf); } String::String(double value, unsigned char decimalPlaces) { init(); - char buf[33]; + char buf[DBL_MAX_10_EXP + 4 + decimalPlaces]; // +4, one for: 10, -, ., \0 *this = dtostrf(value, (decimalPlaces + 2), decimalPlaces, buf); } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy