StreamReader: fix out-of-range exception
parent
b394546e55
commit
a2bbf76cf4
|
@ -284,11 +284,17 @@ bool IOStreamBuffer<T>::getNextDataLine( std::vector<T> &buffer, T continuationT
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
inline
|
||||||
|
bool isEndOfCache( size_t pos, size_t cacheSize ) {
|
||||||
|
return ( pos == cacheSize );
|
||||||
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline
|
inline
|
||||||
bool IOStreamBuffer<T>::getNextLine(std::vector<T> &buffer) {
|
bool IOStreamBuffer<T>::getNextLine(std::vector<T> &buffer) {
|
||||||
buffer.resize(m_cacheSize);
|
buffer.resize(m_cacheSize);
|
||||||
if (m_cachePos == m_cacheSize || 0 == m_filePos) {
|
if ( isEndOfCache( m_cachePos, m_cacheSize ) || 0 == m_filePos) {
|
||||||
if (!readNextBlock()) {
|
if (!readNextBlock()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -300,6 +306,11 @@ bool IOStreamBuffer<T>::getNextLine(std::vector<T> &buffer) {
|
||||||
++m_cachePos;
|
++m_cachePos;
|
||||||
}
|
}
|
||||||
++m_cachePos;
|
++m_cachePos;
|
||||||
|
if ( isEndOfCache( m_cachePos, m_cacheSize ) ) {
|
||||||
|
if ( !readNextBlock() ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
|
|
Loading…
Reference in New Issue