Skip to content

Commit 9ecc150

Browse files
committed
This is a bug fix which prevents parseFloat from proceeding past
multiple decimals '.' in the stream. Only one can be accepted for valid decimal numbers.
1 parent 2e12a79 commit 9ecc150

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

hardware/arduino/avr/cores/arduino/Stream.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ float Stream::parseFloat(char skipChar){
185185
read(); // consume the character we got with peek
186186
c = timedPeek();
187187
}
188-
while( (c >= '0' && c <= '9') || c == '.' || c == skipChar );
188+
while( (c >= '0' && c <= '9') || c == '.' && !isFraction || c == skipChar );
189189

190190
if(isNegative)
191191
value = -value;

hardware/arduino/sam/cores/arduino/Stream.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ float Stream::parseFloat(char skipChar){
185185
read(); // consume the character we got with peek
186186
c = timedPeek();
187187
}
188-
while( (c >= '0' && c <= '9') || c == '.' || c == skipChar );
188+
while( (c >= '0' && c <= '9') || c == '.' && !isFraction || c == skipChar );
189189

190190
if(isNegative)
191191
value = -value;

0 commit comments

Comments
 (0)