From d51f1d3e9307124c93d3a8ca9c26f48420c10c50 Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Thu, 11 Dec 2014 00:50:07 +0100 Subject: tested CharReader.fork and fixed access to uninitialized memory in context function --- src/core/utils/CharReader.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') 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 -- cgit v1.2.3