Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:16.0:FactoryCandidates
nodejs-electron
quiche-QuicIntervalDeque-no-match-for-operator-...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File quiche-QuicIntervalDeque-no-match-for-operator-mm.patch of Package nodejs-electron
From d3bc5ffc929b0895ae9e16774069a04ae6fe3c58 Mon Sep 17 00:00:00 2001 From: bnc <bnc@google.com> Date: Mon, 13 May 2024 12:28:35 -0700 Subject: [PATCH] Add some QuicIntervalDeque::Iterator methods. GCC requires operator-=() and operator--() to be defined for std::advance for random access iterators. Also, `QUICHE_DCHECK_LE(0u, index_)` is always true as `index_` is unsigned, causing a warning that is promoted to an error in some environments. This CL verifies that the addition does not result in underflow before the it is performed, not after. PiperOrigin-RevId: 633296228 --- quiche/quic/core/quic_interval_deque.h | 19 +++++++++-- quiche/quic/core/quic_interval_deque_test.cc | 33 ++++++++++++++++++++ 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/quiche/quic/core/quic_interval_deque.h b/quiche/quic/core/quic_interval_deque.h index db7b2b0ac..1c6cd71a5 100644 --- a/net/third_party/quiche/src/quiche/quic/core/quic_interval_deque.h +++ b/net/third_party/quiche/src/quiche/quic/core/quic_interval_deque.h @@ -158,7 +158,7 @@ class QUICHE_NO_EXPORT QuicIntervalDeque { Iterator(std::size_t index, QuicIntervalDeque* deque) : index_(index), deque_(deque) {} // Only the ++ operator attempts to update the cached index. Other operators - // are used by |lower_bound| to binary search and are thus private. + // are used by |lower_bound| to binary search. Iterator& operator++() { // Don't increment when we are at the end. const std::size_t container_size = deque_->container_.size(); @@ -186,6 +186,19 @@ class QUICHE_NO_EXPORT QuicIntervalDeque { ++(*this); return copy; } + Iterator& operator--() { + if (index_ == 0) { + QUIC_BUG(quic_bug_10862_4) << "Iterator out of bounds."; + return *this; + } + index_--; + return *this; + } + Iterator operator--(int) { + Iterator copy = *this; + --(*this); + return copy; + } reference operator*() { return deque_->container_[index_]; } reference operator*() const { return deque_->container_[index_]; } pointer operator->() { return &deque_->container_[index_]; } @@ -194,11 +207,13 @@ class QUICHE_NO_EXPORT QuicIntervalDeque { } bool operator!=(const Iterator& rhs) const { return !(*this == rhs); } Iterator& operator+=(difference_type amount) { + // `amount` might be negative, check for underflow. + QUICHE_DCHECK_GE(static_cast<difference_type>(index_), -amount); index_ += amount; - QUICHE_DCHECK_LE(0u, index_); QUICHE_DCHECK_LT(index_, deque_->Size()); return *this; } + Iterator& operator-=(difference_type amount) { return operator+=(-amount); } difference_type operator-(const Iterator& rhs) const { return static_cast<difference_type>(index_) - static_cast<difference_type>(rhs.index_);
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor