Skip to content

Commit

Permalink
src: operator[] checks bounds in debug mode
Browse files Browse the repository at this point in the history
PR-URL: #16002
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
  • Loading branch information
GitHubTracey authored and MylesBorins committed Oct 23, 2017
1 parent bc1ad81 commit 26bd574
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/string_search.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ class Vector {

// Access individual vector elements - checks bounds in debug mode.
T& operator[](size_t index) const {
#ifdef DEBUG
CHECK(index < length_);
#endif
return start_[is_forward_ ? index : (length_ - index - 1)];
}

Expand Down

0 comments on commit 26bd574

Please sign in to comment.