Enforce bounds checking in `structured_headers::Dictionary::operator[](size_t)`. Add `QUICHE_CHECK_LT(idx, members_.size())` to both `Dictionary::operator[](size_t)` overloads (which `Dictionary::at(size_t)` also delegates to), aligning their behavior with their header documentation that both `operator[](size_t)` and `at(size_t)` abort the program on out-of-bounds access. PiperOrigin-RevId: 1000942364
diff --git a/quiche/common/structured_headers.cc b/quiche/common/structured_headers.cc index 671a67e..d31ebee 100644 --- a/quiche/common/structured_headers.cc +++ b/quiche/common/structured_headers.cc
@@ -1001,9 +1001,11 @@ Dictionary::iterator Dictionary::end() { return members_.end(); } Dictionary::const_iterator Dictionary::end() const { return members_.end(); } ParameterizedMember& Dictionary::operator[](std::size_t idx) { + QUICHE_CHECK_LT(idx, members_.size()); return members_[idx].second; } const ParameterizedMember& Dictionary::operator[](std::size_t idx) const { + QUICHE_CHECK_LT(idx, members_.size()); return members_[idx].second; } ParameterizedMember& Dictionary::at(std::size_t idx) { return (*this)[idx]; }