fix(core): fixed String::lastIndexOf bug (#9003)
Co-authored-by: Rodrigo Garcia <rodrigo.garcia@espressif.com> Co-authored-by: Vojtěch Bartoška <76958047+VojtechBartoska@users.noreply.github.com>
This commit is contained in:
parent
812a59aadd
commit
f6e12eb7e9
1 changed files with 4 additions and 1 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue