From d5cf2584db4205ace86eb0e2688e06ab207cb182 Mon Sep 17 00:00:00 2001 From: blankie Date: Fri, 20 Jan 2023 21:31:07 +0700 Subject: [PATCH] Fix read bug Reproduction code: import time s = "--------- switch to main\n--------- switch to system\n" print(s[:0xc], end='', flush=True) time.sleep(1) print(s[0xc:], end='', flush=True) --- logcat_thread.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/logcat_thread.cpp b/logcat_thread.cpp index 1954283..6c21648 100644 --- a/logcat_thread.cpp +++ b/logcat_thread.cpp @@ -35,8 +35,8 @@ static inline void look_for_newlines(char buf[NEWLINE_BUF_SIZE], size_t* used, s size_t newline_length = (reinterpret_cast(newline_ptr) - reinterpret_cast(&buf[real_offset])) / sizeof(char); (logcat_thread->*handle_line)(&buf[real_offset], newline_length, is_stdout); - search_offset += newline_length + 1; - real_offset = search_offset; + real_offset += newline_length + 1; + search_offset = real_offset; } if (real_offset) {