diff --git a/misc.c b/misc.c index 7f8d6df..64da6de 100644 --- a/misc.c +++ b/misc.c @@ -54,7 +54,7 @@ wait_for_vcp(void) #if MEM_DEBUG_BUF static char debugbuf[1024]; -static uint32_t debugpos; +static uint32_t debugpos = 0; void debug_printf(const char *format, ...) @@ -75,6 +75,9 @@ debug_printf(const char *format, ...) memcpy(&debugbuf[debugpos], pos, cpy); debugpos += cpy; + if (debugpos >= sizeof debugbuf) + debugpos = 0; + pos += cpy; length -= cpy; }