--- old/src/share/vm/logging/logStream.cpp 2017-06-21 17:45:59.011284600 +0200 +++ new/src/share/vm/logging/logStream.cpp 2017-06-21 17:45:58.112609800 +0200 @@ -41,7 +41,7 @@ void LogStream::LineBuffer::ensure_cap(size_t atleast) { assert(_cap >= sizeof(_smallbuf), "sanity"); - if (_cap < atleast) { + if (_cap < atleast) { const size_t newcap = MAX2(_cap * 2, atleast * 2); char* const newbuf = (char*) os::malloc(newcap, mtLogging); if (_pos > 0) { // preserve old content @@ -58,20 +58,20 @@ void LogStream::LineBuffer::append(const char* s, size_t len) { assert(_buf[_pos] == '\0', "sanity"); - const size_t remaining = _cap - _pos; - ensure_cap(remaining + len + 1); + ensure_cap(_pos + len + 1); + assert(_cap >= _pos + len + 1, "sanity"); memcpy(_buf + _pos, s, len); _pos += len; _buf[_pos] = '\0'; } - + void LogStream::LineBuffer::reset() { _pos = 0; _buf[_pos] = '\0'; } void LogStream::write(const char* s, size_t len) { - + if (len > 0 && s[len - 1] == '\n') { _current_line.append(s, len - 1); // omit the newline. _log_handle.print("%s", _current_line.ptr());