From faebe7a70a43958ea69a4ddfa1812da3f97bd621 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 4 Dec 2025 20:49:57 +0000 Subject: [PATCH] Do not read over buffer if format is a single #, and do not loop forever if UTF-8 is unfinished in a format. Reported by Giorgi Kobakhia im GitHub issue 4735. --- format-draw.c | 2 -- format.c | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/format-draw.c b/format-draw.c index efc6ab1a..c8cb74b6 100644 --- a/format-draw.c +++ b/format-draw.c @@ -1104,8 +1104,6 @@ format_width(const char *expanded) more = utf8_append(&ud, *cp); if (more == UTF8_DONE) width += ud.width; - else - cp -= ud.have; } else if (*cp > 0x1f && *cp < 0x7f) { width++; cp++; diff --git a/format.c b/format.c index 17a9dd53..3d498b34 100644 --- a/format.c +++ b/format.c @@ -5545,7 +5545,8 @@ format_expand1(struct format_expand_state *es, const char *fmt) buf[off++] = *fmt++; continue; } - fmt++; + if (*fmt++ == '\0') + break; ch = (u_char)*fmt++; switch (ch) {