Skip to content

Commit

Permalink
Checking indices before dereference (#2040)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomsonTan authored Mar 14, 2023
1 parent b046764 commit 15ab9ed
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 15ab9ed

Please sign in to comment.