diff --git a/queue.cpp b/queue.cpp index 5b9aed22..bc149522 100644 --- a/queue.cpp +++ b/queue.cpp @@ -11,7 +11,7 @@ NAMESPACE_BEGIN(CryptoPP) -static const unsigned int s_maxAutoNodeSize = 16*1024; +static const unsigned int s_maxAutoNodeSize = 16*1024u; // this class for use by ByteQueue only class ByteQueueNode @@ -136,8 +136,9 @@ public: // ******************************************************** ByteQueue::ByteQueue(size_t nodeSize) - : Bufferless(), m_autoNodeSize(!nodeSize), m_nodeSize(nodeSize) - , m_head(NULLPTR), m_tail(NULLPTR), m_lazyString(NULLPTR), m_lazyLength(0), m_lazyStringModifiable(false) + : Bufferless() + , m_head(NULLPTR), m_tail(NULLPTR), m_lazyString(NULLPTR), m_lazyLength(0) + , m_nodeSize(nodeSize), m_lazyStringModifiable(false), m_autoNodeSize(!nodeSize) { // See GH #962 for the reason for this assert. CRYPTOPP_ASSERT(nodeSize != SIZE_MAX); @@ -476,18 +477,18 @@ bool ByteQueue::operator==(const ByteQueue &rhs) const return true; } -byte ByteQueue::operator[](lword i) const +byte ByteQueue::operator[](lword index) const { for (ByteQueueNode *current=m_head; current; current=current->m_next) { - if (i < current->CurrentSize()) - return (*current)[(size_t)i]; + if (index < current->CurrentSize()) + return (*current)[(size_t)index]; - i -= current->CurrentSize(); + index -= current->CurrentSize(); } - CRYPTOPP_ASSERT(i < m_lazyLength); - return m_lazyString[i]; + CRYPTOPP_ASSERT(index < m_lazyLength); + return m_lazyString[index]; } void ByteQueue::swap(ByteQueue &rhs) diff --git a/queue.h b/queue.h index 00e7e4a8..e74244b5 100644 --- a/queue.h +++ b/queue.h @@ -127,7 +127,7 @@ public: void FinalizeLazyPut(); /// \brief Assign contents from another ByteQueue - /// \param t the other ByteQueue + /// \param rhs the other ByteQueue /// \return reference to this ByteQueue ByteQueue & operator=(const ByteQueue &rhs); @@ -149,7 +149,7 @@ public: /// \param index of byte to retrieve /// \return byte at the specified index /// \details operator[]() does not perform bounds checking. - byte operator[](lword i) const; + byte operator[](lword index) const; /// \brief Swap contents with another ByteQueue /// \param rhs the other SecBlock