-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Update ArduinoOTA.cpp to solve #4086 #4090
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -146,26 +146,26 @@ int ArduinoOTAClass::parseInt(){ | |
| uint8_t index; | ||
| char value; | ||
| while(_udp_ota->peek() == ' ') _udp_ota->read(); | ||
| for(index = 0; index < sizeof(data); ++index){ | ||
| for(index = 0; index < sizeof(data); index++){ | ||
|
||
| value = _udp_ota->peek(); | ||
| if(value < '0' || value > '9'){ | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This if statement needs a check against peek error return: if(value < 0 || everythingelse) |
||
| data[index++] = '\0'; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For me, it would be even clearer to not increment the index here, something like this:
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be data[index] = '\0'; |
||
| return atoi(data); | ||
| } | ||
| data[index++] = _udp_ota->read(); | ||
| data[index] = _udp_ota->read(); | ||
| } | ||
| return 0; | ||
| } | ||
|
|
||
| String ArduinoOTAClass::readStringUntil(char end){ | ||
| String res = ""; | ||
| int value; | ||
| char value; | ||
|
||
| while(true){ | ||
| value = _udp_ota->read(); | ||
| if(value < 0 || value == '\0' || value == end){ | ||
| if(value < '0' || value == '\0' || value == end){ | ||
|
||
| return res; | ||
| } | ||
| res += static_cast<char>(value); | ||
| res += value; | ||
|
||
| } | ||
| return res; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
value should be declared int, because peek() returns an int that can be -1 on error