Skip to content

Commit

Permalink
fix(core): fixed String::lastIndexOf bug (#9003)
Browse files Browse the repository at this point in the history
Co-authored-by: Rodrigo Garcia <[email protected]>
Co-authored-by: Vojtěch Bartoška <[email protected]>
  • Loading branch information
3 people authored Dec 20, 2023
1 parent 812a59a commit f6e12eb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cores/esp32/WString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,10 @@ int String::lastIndexOf(char ch, unsigned int fromIndex) const {
wbuffer()[fromIndex + 1] = tempchar;
if(temp == NULL)
return -1;
return temp - buffer();
const int rv = temp - buffer();
if(rv >= len())
return -1;
return rv;
}

int String::lastIndexOf(const String &s2) const {
Expand Down

0 comments on commit f6e12eb

Please sign in to comment.