Fixes String(float) issue with Stack Smashing (#6138)

Fixes #5873
This commit is contained in:
Rodrigo Garcia
2022-01-17 09:44:49 -03:00
committed by GitHub
parent caef4006af
commit 841599c248
4 changed files with 23 additions and 11 deletions

View File

@ -88,7 +88,7 @@ char* ultoa(unsigned long value, char* result, int base) {
return result;
}
char * dtostrf(double number, signed char width, unsigned char prec, char *s) {
char * dtostrf(double number, signed int width, unsigned int prec, char *s) {
bool negative = false;
if (isnan(number)) {
@ -117,7 +117,7 @@ char * dtostrf(double number, signed char width, unsigned char prec, char *s) {
// Round correctly so that print(1.999, 2) prints as "2.00"
// I optimized out most of the divisions
double rounding = 2.0;
for (uint8_t i = 0; i < prec; ++i)
for (uint32_t i = 0; i < prec; ++i)
rounding *= 10.0;
rounding = 1.0 / rounding;