From 55b9d8142977dcba03a6b701db6d20ec5a4ecf70 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 8 Mar 2026 01:15:33 -1000 Subject: [PATCH] Add diagnostic message before abort on buffer overflow --- esphome/components/rp2040/printf_stubs.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/esphome/components/rp2040/printf_stubs.cpp b/esphome/components/rp2040/printf_stubs.cpp index 83d916cd2c9..c2174a1dece 100644 --- a/esphome/components/rp2040/printf_stubs.cpp +++ b/esphome/components/rp2040/printf_stubs.cpp @@ -32,6 +32,9 @@ static int write_printf_buffer(FILE *stream, char *buf, int len) { size_t write_len = len; if (write_len >= PRINTF_BUFFER_SIZE) { fwrite(buf, 1, PRINTF_BUFFER_SIZE - 1, stream); + // Use fwrite for the message to avoid recursive __wrap_printf call + static const char msg[] = "\nprintf buffer overflow\n"; + fwrite(msg, 1, sizeof(msg) - 1, stream); abort(); } if (fwrite(buf, 1, write_len, stream) < write_len || ferror(stream)) {