Add diagnostic message before abort on buffer overflow

This commit is contained in:
J. Nick Koston
2026-03-08 01:15:33 -10:00
parent 76a35df85a
commit 55b9d81429
@@ -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)) {