From 545312c25170f52cab978bcf3fca267896a747d2 Mon Sep 17 00:00:00 2001 From: Kenichi Handa Date: Tue, 30 Dec 2008 00:46:13 +0000 Subject: [PATCH] (font_intern_prop): Validate str as multibyte. --- src/ChangeLog | 4 ++++ src/font.c | 18 +++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index a459eac160..e362b323d9 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2008-12-30 Kenichi Handa + + * font.c (font_intern_prop): Validate str as multibyte. + 2008-12-29 Dan Nicolaescu * dispextern.h (struct face): Move lface and hash from the middle diff --git a/src/font.c b/src/font.c index 2f98141b53..0c9a625e77 100644 --- a/src/font.c +++ b/src/font.c @@ -254,6 +254,7 @@ font_intern_prop (str, len, force_symbol) int i; Lisp_Object tem; Lisp_Object obarray; + int nbytes, nchars; if (len == 1 && *str == '*') return Qnil; @@ -266,14 +267,25 @@ font_intern_prop (str, len, force_symbol) return make_number (atoi (str)); } - /* The following code is copied from the function intern (in lread.c). */ + /* The following code is copied from the function intern (in + lread.c), and modified to suite our purpose. */ obarray = Vobarray; if (!VECTORP (obarray) || XVECTOR (obarray)->size == 0) obarray = check_obarray (obarray); - tem = oblookup (obarray, str, len, len); + parse_str_as_multibyte (str, len, &nchars, &nbytes); + if (len == nchars || len != nbytes) + /* CONTENTS contains no multibyte sequences or contains an invalid + multibyte sequence. We'll make a unibyte string. */ + tem = oblookup (obarray, str, len, len); + else + tem = oblookup (obarray, str, nchars, len); if (SYMBOLP (tem)) return tem; - return Fintern (make_unibyte_string (str, len), obarray); + if (len == nchars || len != nbytes) + tem = make_unibyte_string (str, len); + else + tem = make_multibyte_string (str, nchars, len); + return Fintern (tem, obarray); } /* Return a pixel size of font-spec SPEC on frame F. */ -- 2.20.1