diff options
author | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2014-12-11 00:50:07 +0100 |
---|---|---|
committer | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2014-12-11 00:50:07 +0100 |
commit | d51f1d3e9307124c93d3a8ca9c26f48420c10c50 (patch) | |
tree | ffdb3d8a15c6185571bd83c553ba255615531a62 /src | |
parent | 2990d12ccca8ddbf0761cf84ce29f38de9f3262c (diff) |
tested CharReader.fork and fixed access to uninitialized memory in context function
Diffstat (limited to 'src')
-rw-r--r-- | src/core/utils/CharReader.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/core/utils/CharReader.cpp b/src/core/utils/CharReader.cpp index effc587..c661b6f 100644 --- a/src/core/utils/CharReader.cpp +++ b/src/core/utils/CharReader.cpp @@ -525,6 +525,7 @@ CharReader::Context CharReader::getContext(ssize_t maxSize) // Fetch the character at the current position if (buffer->fetch(cur, c)) { // Abort, at linebreaks if we found a non-linebreak character + hadNonWhitespace = hadNonWhitespace || !Utils::isWhitespace(c); if (hadNonWhitespace && (c == '\n' || c == '\r')) { buffer->moveCursor(cur, 1); start++; @@ -535,11 +536,10 @@ CharReader::Context CharReader::getContext(ssize_t maxSize) if (buffer->moveCursor(cur, -1) == 0) { foundBegin = true; break; + } else { + // Update the start position and the hadNonWhitespace flag + start--; } - - // Update the start position and the hadNonWhitespace flag - hadNonWhitespace = hadNonWhitespace || !Utils::isWhitespace(c); - start--; } // Search the end of the line |