unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
To: Stefan Kangas <stefan@marxist.se>
Cc: 36507@debbugs.gnu.org
Subject: bug#36507: 27.0.50; Crash on evaluating invalid UTF-8 byte sequence on MacOS
Date: Fri, 05 Jul 2019 11:22:45 +0900	[thread overview]
Message-ID: <wlv9whnrt6.wl-mituharu@math.s.chiba-u.ac.jp> (raw)
In-Reply-To: <CADwFkm=_zJ3rUK9vM40HAGOYOnFyqhLmWYQUT2Mef4aPFaENFQ@mail.gmail.com>

On Fri, 05 Jul 2019 11:04:21 +0900,
Stefan Kangas wrote:
> 
> When evaluating the following expression, I get a crash under "emacs -Q"
> compiled from current master.
> 
> (decode-coding-string "\xE3\x32\x9A\x36" 'chinese-gb18030)
> 
> This expression is tested in batch mode with no problems on the same
> system, now on master in test/lisp/bookmark-tests.el:281.
> 
> The expression was suggested in Bug#36452, where
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> > Please add to that text something that doesn't yield valid
> > UTF-8 byte sequence.  For example, these two strings:
> >
> >   (decode-coding-string "\xE3\x32\x9A\x36" 'chinese-gb18030)
> 
> I think the issue as such is beyond me, but I can reproduce this every time.
> Please let me know if you need help testing or more information.
> 
> Before crash, I get this output:
> Thread 1 received signal SIGSEGV, Segmentation fault.
> 0x00007fff8ddbd326 in CFCharacterSetIsLongCharacterMember () from
> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation

Please try the patch below.

				     YAMAMOTO Mitsuharu
				mituharu@math.s.chiba-u.ac.jp

diff --git a/src/macfont.m b/src/macfont.m
index f736fbf0e1e..2b7f963fd61 100644
--- a/src/macfont.m
+++ b/src/macfont.m
@@ -2076,7 +2076,7 @@ static int macfont_variation_glyphs (struct font *, int c,
               ptrdiff_t j;
 
               for (j = 0; j < ASIZE (chars); j++)
-                if (TYPE_RANGED_FIXNUMP (UTF32Char, AREF (chars, j))
+                if (RANGED_FIXNUMP (0, AREF (chars, j), MAX_UNICODE_CHAR)
                     && CFCharacterSetIsLongCharacterMember (desc_charset,
                                                             XFIXNAT (AREF (chars, j))))
                   break;
@@ -2710,6 +2710,9 @@ So we use CTFontDescriptorCreateMatchingFontDescriptor (no
   int result;
   CFCharacterSetRef charset;
 
+  if (c < 0 || c > MAX_UNICODE_CHAR)
+    return false;
+
   block_input ();
   if (FONT_ENTITY_P (font))
     {





  reply	other threads:[~2019-07-05  2:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-05  2:04 bug#36507: 27.0.50; Crash on evaluating invalid UTF-8 byte sequence on MacOS Stefan Kangas
2019-07-05  2:22 ` YAMAMOTO Mitsuharu [this message]
2019-07-05 11:36   ` Stefan Kangas
2019-07-06  5:26     ` YAMAMOTO Mitsuharu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=wlv9whnrt6.wl-mituharu@math.s.chiba-u.ac.jp \
    --to=mituharu@math.s.chiba-u.ac.jp \
    --cc=36507@debbugs.gnu.org \
    --cc=stefan@marxist.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).