Subject: Re: bug#29609: 27.0.50; Format number as hexadecimal with hash-flag

From: Paul Eggert <[email-masked]>
Date: Fri, 8 Dec 2017 13:31:21 -0800

On 12/08/2017 09:51 AM, Glenn Morris wrote:
> Could there be something wrong with 47423f0?

Yes there could, and thanks for reporting it. I installed the attached 
to fix the bug I recently introduced.

>From c9d450ffcc755c4af39c2ab5a9e585f05eeddf94 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
Date: Fri, 8 Dec 2017 13:30:06 -0800
Subject: [PATCH] Fix core dump from (format "%#08x" n) patch

Problem reported by Glenn Morris (Bug#29609#13).
* src/editfns.c (styled_format): Null-terminate output,
as later code now expects this.
---
 src/editfns.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/editfns.c b/src/editfns.c
index ebf6518994..084d92346f 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -4623,6 +4623,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message)
 		  /* Don't use sprintf here, as it might mishandle prec.  */
 		  sprintf_buf[0] = XINT (arg);
 		  sprintf_bytes = prec != 0;
+		  sprintf_buf[sprintf_bytes] = '\0';
 		}
 	      else if (conversion == 'd' || conversion == 'i')
 		{
-- 
2.14.3