You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
while (str[static_cast<std::size_t>(left)] == ' ' && left <= right)
should be:
while (left <= right && str[static_cast<std::size_t>(left)] == ' ')
In both cases the boundary check (left <= right) must be done first, and then read character from the array.
This was caught with HAVE_CPP_STDLIB=1 and -c dbg on //api/test/common:string_util_test (in bazel) using MSVC
It doesn't trigger error in fastbld/opt which makes me thing the MSVC standard string_view throws an exception there.
Probably as room for improvement, the nostd::string_view should also throw an exception (in debug) if this happens.
Not sure how gcc/clang work.