From e75beaa8d69a3ae79ee88f5de04cd4ec0db8b622 Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Mon, 15 Oct 2018 10:46:24 -0400 Subject: [PATCH] Make android logging thread only process buffer slice that contains real data. --- ports/libsimpleservo/src/jniapi.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ports/libsimpleservo/src/jniapi.rs b/ports/libsimpleservo/src/jniapi.rs index efb67ff741e..00487b417eb 100644 --- a/ports/libsimpleservo/src/jniapi.rs +++ b/ports/libsimpleservo/src/jniapi.rs @@ -491,6 +491,9 @@ fn redirect_stdout_to_logcat() { result as usize + cursor }; + // Only modify the portion of the buffer that contains real data. + let buf = &mut buf[0..end]; + if let Some(last_newline_pos) = buf.iter().rposition(|&c| c == b'\n' as c_char) { buf[last_newline_pos] = b'\0' as c_char; unsafe {