Skip to content

Commit 26bd574

Browse files
GitHubTraceyMylesBorins
authored andcommitted
src: operator[] checks bounds in debug mode
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>
1 parent bc1ad81 commit 26bd574

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/string_search.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ class Vector {
4444

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

0 commit comments

Comments
 (0)