diff --git a/src/sys/log.rs b/src/sys/log.rs index 6ac42890c..7bd4c70af 100644 --- a/src/sys/log.rs +++ b/src/sys/log.rs @@ -32,14 +32,15 @@ impl LogBuffer { impl core::fmt::Write for LogBuffer { fn write_str(&mut self, s: &str) -> core::fmt::Result { + if self.len + s.len() > LOG_SIZE { + self.len = 0; + self.buf.fill(0); + } + let bytes = s.as_bytes(); let i = self.len; let n = i + bytes.len(); - if n > LOG_SIZE { - return Err(core::fmt::Error); - } - self.buf[i..n].copy_from_slice(bytes); self.len += bytes.len();