diff options
| author | Kenichi Handa | 2008-12-30 00:46:13 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2008-12-30 00:46:13 +0000 |
| commit | 545312c25170f52cab978bcf3fca267896a747d2 (patch) | |
| tree | aee8f07e68ffb899c1f9bd164a54427b9b714ab9 /src | |
| parent | 25f01375540129388139e25163c2cdd6f4b20f48 (diff) | |
| download | emacs-545312c25170f52cab978bcf3fca267896a747d2.tar.gz emacs-545312c25170f52cab978bcf3fca267896a747d2.zip | |
(font_intern_prop): Validate str as multibyte.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 4 | ||||
| -rw-r--r-- | src/font.c | 18 |
2 files changed, 19 insertions, 3 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index a459eac1608..e362b323d97 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2008-12-30 Kenichi Handa <handa@m17n.org> | ||
| 2 | |||
| 3 | * font.c (font_intern_prop): Validate str as multibyte. | ||
| 4 | |||
| 1 | 2008-12-29 Dan Nicolaescu <dann@ics.uci.edu> | 5 | 2008-12-29 Dan Nicolaescu <dann@ics.uci.edu> |
| 2 | 6 | ||
| 3 | * dispextern.h (struct face): Move lface and hash from the middle | 7 | * dispextern.h (struct face): Move lface and hash from the middle |
diff --git a/src/font.c b/src/font.c index 2f98141b53d..0c9a625e770 100644 --- a/src/font.c +++ b/src/font.c | |||
| @@ -254,6 +254,7 @@ font_intern_prop (str, len, force_symbol) | |||
| 254 | int i; | 254 | int i; |
| 255 | Lisp_Object tem; | 255 | Lisp_Object tem; |
| 256 | Lisp_Object obarray; | 256 | Lisp_Object obarray; |
| 257 | int nbytes, nchars; | ||
| 257 | 258 | ||
| 258 | if (len == 1 && *str == '*') | 259 | if (len == 1 && *str == '*') |
| 259 | return Qnil; | 260 | return Qnil; |
| @@ -266,14 +267,25 @@ font_intern_prop (str, len, force_symbol) | |||
| 266 | return make_number (atoi (str)); | 267 | return make_number (atoi (str)); |
| 267 | } | 268 | } |
| 268 | 269 | ||
| 269 | /* The following code is copied from the function intern (in lread.c). */ | 270 | /* The following code is copied from the function intern (in |
| 271 | lread.c), and modified to suite our purpose. */ | ||
| 270 | obarray = Vobarray; | 272 | obarray = Vobarray; |
| 271 | if (!VECTORP (obarray) || XVECTOR (obarray)->size == 0) | 273 | if (!VECTORP (obarray) || XVECTOR (obarray)->size == 0) |
| 272 | obarray = check_obarray (obarray); | 274 | obarray = check_obarray (obarray); |
| 273 | tem = oblookup (obarray, str, len, len); | 275 | parse_str_as_multibyte (str, len, &nchars, &nbytes); |
| 276 | if (len == nchars || len != nbytes) | ||
| 277 | /* CONTENTS contains no multibyte sequences or contains an invalid | ||
| 278 | multibyte sequence. We'll make a unibyte string. */ | ||
| 279 | tem = oblookup (obarray, str, len, len); | ||
| 280 | else | ||
| 281 | tem = oblookup (obarray, str, nchars, len); | ||
| 274 | if (SYMBOLP (tem)) | 282 | if (SYMBOLP (tem)) |
| 275 | return tem; | 283 | return tem; |
| 276 | return Fintern (make_unibyte_string (str, len), obarray); | 284 | if (len == nchars || len != nbytes) |
| 285 | tem = make_unibyte_string (str, len); | ||
| 286 | else | ||
| 287 | tem = make_multibyte_string (str, nchars, len); | ||
| 288 | return Fintern (tem, obarray); | ||
| 277 | } | 289 | } |
| 278 | 290 | ||
| 279 | /* Return a pixel size of font-spec SPEC on frame F. */ | 291 | /* Return a pixel size of font-spec SPEC on frame F. */ |