test icon indicating copy to clipboard operation
test copied to clipboard

Fix undefined behavior in `basic_cstring::rfind`

Open Flamefire opened this issue 3 years ago • 0 comments

Getting the pointer to 1-before an array is undefined behavior, i.e. begin() - 1 is not allowed. So modify rfind to loop until the front and do a final comparison with begin()/first afterwards before returning npos. Use a better-suited for-loop and modify find to look as similar as possible so the difference is easy to spot.

Fixes #357

Flamefire avatar Oct 10 '22 11:10 Flamefire