bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#43409: 28.0.50; Segfault on non-UTF-8 path


From: Eli Zaretskii
Subject: bug#43409: 28.0.50; Segfault on non-UTF-8 path
Date: Tue, 15 Sep 2020 17:15:06 +0300

> From: Lars Ingebrigtsen <larsi@gnus.org>
> Date: Tue, 15 Sep 2020 02:16:36 +0200
> 
> Hitting RET on that kills Emacs.  Running under gdb, I get this
> backtrace:
> 
> #0  terminate_due_to_signal
>     (sig=sig@entry=6, backtrace_limit=backtrace_limit@entry=40) at emacs.c:378
> #1  0x00005555555984fe in emacs_abort () at sysdep.c:2280
> #2  0x0000555555596a9a in multibyte_chars_in_text (ptr=<optimized out>, 
>     ptr@entry=0x5555565f0870 "f\363o", nbytes=nbytes@entry=3)
>     at character.c:447
> #3  0x00005555555d412b in display_mode_element
>     (it=<optimized out>, depth=<optimized out>, field_width=<optimized out>, 
> precision=<optimized out>, elt=<optimized out>, props=<optimized out>, 
> risky=<optimized out>) at xdisp.c:25644

My bad, sorry: I used a wrong API for the job.  Does the below solve
the problem?

diff --git a/src/xdisp.c b/src/xdisp.c
index 10ddb53dba..615f0ca7cf 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -25641,8 +25641,10 @@ display_mode_element (struct it *it, int depth, int 
field_width, int precision,
                    /* Non-ASCII characters in SPEC should cause mode-line
                       element be displayed as a multibyte string.  */
                    ptrdiff_t nbytes = strlen (spec);
-                   if (multibyte_chars_in_text ((const unsigned char *)spec,
-                                                nbytes) != nbytes)
+                   ptrdiff_t nchars, mb_nbytes;
+                   parse_str_as_multibyte ((const unsigned char *)spec, nbytes,
+                                           &nchars, &mb_nbytes);
+                   if (!(nbytes == nchars || nbytes != mb_nbytes))
                      multibyte = true;
 
                    switch (mode_line_target)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]