diff --git a/src/string.cpp b/src/string.cpp index f511a95..678af66 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -375,7 +375,7 @@ namespace bx inline const char* strRFindUnsafe(const char* _str, int32_t _len, char _ch) { - for (int32_t ii = _len; 0 <= ii; --ii) + for (int32_t ii = _len-1; 0 <= ii; --ii) { if (_str[ii] == _ch) { diff --git a/tests/string_test.cpp b/tests/string_test.cpp index 5919964..c1c4b85 100644 --- a/tests/string_test.cpp +++ b/tests/string_test.cpp @@ -188,6 +188,7 @@ TEST_CASE("strRFind", "") REQUIRE(bx::strRFind(bx::StringView(test, 0), 's').isEmpty() ); REQUIRE(bx::strRFind(bx::StringView(test, 1), 's').isEmpty() ); REQUIRE(&test[2] == bx::strRFind(test, 's').getPtr() ); + REQUIRE(&test[3] == bx::strRFind(test, 't').getPtr() ); } TEST_CASE("strFindI", "")