[Top][All Lists]

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

master f4b4166: Avoid aborts in display_mode_element

From: Eli Zaretskii
Subject: master f4b4166: Avoid aborts in display_mode_element
Date: Tue, 15 Sep 2020 11:44:41 -0400 (EDT)

branch: master
commit f4b4166e0075943641cd75c5935959cdc157c585
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>

    Avoid aborts in display_mode_element
    * src/xdisp.c (display_mode_element): Use parse_str_as_multibyte,
    not multibyte_chars_in_text, to determine whether mode-line spec
    shall be displayed as a multibyte or unibyte string.  We cannot
    use multibyte_chars_in_text here because it aborts when it finds
    raw bytes in the spec string.  (Bug#43409)
 src/xdisp.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/xdisp.c b/src/xdisp.c
index 10ddb53..615f0ca 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]