From 8f1670b40fc9a779303207710a913b769170e82a Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Sun, 29 Sep 2019 14:32:02 +0200 Subject: [PATCH] don't crash when trying to format a very long string --- src/comp.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/comp.c b/src/comp.c index 48ddba7eb27..f55aa8191e3 100644 --- a/src/comp.c +++ b/src/comp.c @@ -205,7 +205,11 @@ format_string (const char *format, ...) va_start (va, format); int res = vsnprintf (scratch_area, sizeof (scratch_area), format, va); if (res >= sizeof (scratch_area)) - error ("Truncating string"); + { + scratch_area[sizeof (scratch_area) - 4] = '.'; + scratch_area[sizeof (scratch_area) - 3] = '.'; + scratch_area[sizeof (scratch_area) - 2] = '.'; + } va_end (va); return scratch_area; } @@ -302,7 +306,7 @@ register_emitter (Lisp_Object key, void *func) Fputhash (key, value, comp.emitter_dispatcher); } -INLINE static void +static void emit_comment (const char *str) { if (COMP_DEBUG) -- 2.39.5