diff options
author | MarcoFalke <falke.marco@gmail.com> | 2019-01-05 15:06:38 +0100 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2019-01-05 15:06:43 +0100 |
commit | 88bbcdc4e9b6e745934a34dd3a9f4ec596d2cff7 (patch) | |
tree | 8284c9bffdaf70fb5de9754104320a3fa9bfa24f /src/streams.h | |
parent | fe5a70b9fefa0548f497a749746f53f3d7fd0ebb (diff) | |
parent | 4f4993fe2ac25cb2676d35a98e2b22da1add1bb1 (diff) |
Merge #14357: streams: Fix broken streams_vector_reader test. Remove unused seek(size_t).
4f4993fe2a Remove UBSan suppression (practicalswift)
958e1a307e streams: Remove unused seek(size_t) (practicalswift)
Pull request description:
Fix broken `streams_vector_reader` test. Remove unused `seek(size_t)`.
Before this change the test `streams_vector_reader` triggered an unintended unsigned integer wraparound. It tried so seek using a negative value in `reader.seek(-6)`.
Changes in this PR:
* Fix broken `VectorReader::seek(size_t)` test case
* Remove unused `seek(size_t)`
Tree-SHA512: 6c6affd680626363eef9e496748f2f86a522325abab9d6b13161f41125cdc29ceb36c2c1509c90b8ff108d606df7629e55e094cc2b6253b05a892b81ce176b71
Diffstat (limited to 'src/streams.h')
-rw-r--r-- | src/streams.h | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/src/streams.h b/src/streams.h index 8010a061c7..0809c96be1 100644 --- a/src/streams.h +++ b/src/streams.h @@ -120,12 +120,6 @@ class CVectorWriter { return nType; } - void seek(size_t nSize) - { - nPos += nSize; - if(nPos > vchData.size()) - vchData.resize(nPos); - } private: const int nType; const int nVersion; @@ -152,9 +146,11 @@ public: * @param[in] pos Starting position. Vector index where reads should start. */ VectorReader(int type, int version, const std::vector<unsigned char>& data, size_t pos) - : m_type(type), m_version(version), m_data(data) + : m_type(type), m_version(version), m_data(data), m_pos(pos) { - seek(pos); + if (m_pos > m_data.size()) { + throw std::ios_base::failure("VectorReader(...): end of data (m_pos > m_data.size())"); + } } /* @@ -197,14 +193,6 @@ public: memcpy(dst, m_data.data() + m_pos, n); m_pos = pos_next; } - - void seek(size_t n) - { - m_pos += n; - if (m_pos > m_data.size()) { - throw std::ios_base::failure("VectorReader::seek(): end of data"); - } - } }; /** Double ended buffer combining vector and stream-like interfaces. |