When "getNextBlock" was called after "getNextLine", the pointer could still on the newline.

The pointer to a newline could not advance enough, when the line ended with \r\n. The resulting buffer was correct, as the buffer range went from <start> until \r, but that the pointer increased by just 1 could lead to the problem that the next pointer points at \n, which is still part of the newline and therefore, "getNextBlock" got 1 byte too much.

Refs Issue #4871
This commit is contained in:
Matthias Möller
2023-02-04 15:16:22 +01:00
parent 8c6b3fe69a
commit db72c6ee38
4 changed files with 19 additions and 1 deletions

View File

@@ -323,7 +323,9 @@ AI_FORCE_INLINE bool IOStreamBuffer<T>::getNextLine(std::vector<T> &buffer) {
}
}
buffer[i] = '\n';
while (m_cachePos < m_cacheSize && (m_cache[m_cachePos] == '\r' || m_cache[m_cachePos] == '\n')) {
++m_cachePos;
}
return true;
}