Skip to content

Commit

Permalink
Checking indices before dereference
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomsonTan committed Mar 9, 2023
1 parent 5046443 commit d9f2def
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions api/include/opentelemetry/common/string_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ class StringUtil
public:
static nostd::string_view Trim(nostd::string_view str, size_t left, size_t right) noexcept
{
while (str[static_cast<std::size_t>(left)] == ' ' && left <= right)
while (left <= right && str[static_cast<std::size_t>(left)] == ' ')
{
left++;
}
while (str[static_cast<std::size_t>(right)] == ' ' && left <= right)
while (left <= right && str[static_cast<std::size_t>(right)] == ' ')
{
right--;
}
Expand Down

0 comments on commit d9f2def

Please sign in to comment.