diff --git a/src/plugins/output_format/ostream.cpp b/src/plugins/output_format/ostream.cpp index d5f9ffaf3..0a7011a42 100644 --- a/src/plugins/output_format/ostream.cpp +++ b/src/plugins/output_format/ostream.cpp @@ -145,13 +145,15 @@ class StrBuf : public std::stringbuf // this is required because of printf() logging fflush(stdout); - for (auto size = pptr() - pbase(); size > 0; ) + auto size_remains = pptr() - pbase(); + char* current_position = pbase(); + while (size_remains > 0) { - auto written = write(STDOUT_FILENO, pbase(), size); + ssize_t written = write(STDOUT_FILENO, current_position, size_remains); if (written < 0) return -1; - size -= written; - seekoff(written, std::ios_base::cur, std::ios_base::out); + size_remains -= written; + current_position += written; } seekpos(0); return 0;