diff options
| author | Paul Eggert | 2020-06-02 18:40:10 -0700 |
|---|---|---|
| committer | Paul Eggert | 2020-06-02 18:41:02 -0700 |
| commit | 188dc2e5a3cb2de69ec14715ba288ab1e30da6eb (patch) | |
| tree | dd24cab883e91296a3ed246f75d33a083ad8067c | |
| parent | 0bfc4b3dd36a415f118b4b67bfacf99efd6f28c5 (diff) | |
| download | emacs-188dc2e5a3cb2de69ec14715ba288ab1e30da6eb.tar.gz emacs-188dc2e5a3cb2de69ec14715ba288ab1e30da6eb.zip | |
Fix bug in recent byte-code checking hoist
Problem reported by Daniel Colascione (Bug#41680).
* src/lread.c (read1): Check that AREF (tmp, COMPILED_BYTECODE)
is a string before subjecting it to STRING_MULTIBYTE.
Be more consistent about using AREF in the neighborhood,
to help prevent this sort of problem from recurring.
| -rw-r--r-- | src/lread.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/lread.c b/src/lread.c index 29deddaf15f..8064bf4d0eb 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -2966,17 +2966,18 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list) | |||
| 2966 | struct Lisp_Vector *vec; | 2966 | struct Lisp_Vector *vec; |
| 2967 | tmp = read_vector (readcharfun, 1); | 2967 | tmp = read_vector (readcharfun, 1); |
| 2968 | vec = XVECTOR (tmp); | 2968 | vec = XVECTOR (tmp); |
| 2969 | if (! (COMPILED_STACK_DEPTH < vec->header.size | 2969 | if (! (COMPILED_STACK_DEPTH < ASIZE (tmp) |
| 2970 | && (FIXNUMP (vec->contents[COMPILED_ARGLIST]) | 2970 | && (FIXNUMP (AREF (tmp, COMPILED_ARGLIST)) |
| 2971 | || CONSP (vec->contents[COMPILED_ARGLIST]) | 2971 | || CONSP (AREF (tmp, COMPILED_ARGLIST)) |
| 2972 | || NILP (vec->contents[COMPILED_ARGLIST])) | 2972 | || NILP (AREF (tmp, COMPILED_ARGLIST))) |
| 2973 | && ((STRINGP (vec->contents[COMPILED_BYTECODE]) | 2973 | && ((STRINGP (AREF (tmp, COMPILED_BYTECODE)) |
| 2974 | && VECTORP (vec->contents[COMPILED_CONSTANTS])) | 2974 | && VECTORP (AREF (tmp, COMPILED_CONSTANTS))) |
| 2975 | || CONSP (vec->contents[COMPILED_BYTECODE])) | 2975 | || CONSP (AREF (tmp, COMPILED_BYTECODE))) |
| 2976 | && FIXNATP (vec->contents[COMPILED_STACK_DEPTH]))) | 2976 | && FIXNATP (AREF (tmp, COMPILED_STACK_DEPTH)))) |
| 2977 | invalid_syntax ("Invalid byte-code object"); | 2977 | invalid_syntax ("Invalid byte-code object"); |
| 2978 | 2978 | ||
| 2979 | if (STRING_MULTIBYTE (AREF (tmp, COMPILED_BYTECODE))) | 2979 | if (STRINGP (AREF (tmp, COMPILED_BYTECODE)) |
| 2980 | && STRING_MULTIBYTE (AREF (tmp, COMPILED_BYTECODE))) | ||
| 2980 | { | 2981 | { |
| 2981 | /* BYTESTR must have been produced by Emacs 20.2 or earlier | 2982 | /* BYTESTR must have been produced by Emacs 20.2 or earlier |
| 2982 | because it produced a raw 8-bit string for byte-code and | 2983 | because it produced a raw 8-bit string for byte-code and |
| @@ -2987,7 +2988,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list) | |||
| 2987 | Fstring_as_unibyte (AREF (tmp, COMPILED_BYTECODE))); | 2988 | Fstring_as_unibyte (AREF (tmp, COMPILED_BYTECODE))); |
| 2988 | } | 2989 | } |
| 2989 | 2990 | ||
| 2990 | if (COMPILED_DOC_STRING < vec->header.size | 2991 | if (COMPILED_DOC_STRING < ASIZE (tmp) |
| 2991 | && EQ (AREF (tmp, COMPILED_DOC_STRING), make_fixnum (0))) | 2992 | && EQ (AREF (tmp, COMPILED_DOC_STRING), make_fixnum (0))) |
| 2992 | { | 2993 | { |
| 2993 | /* read_list found a docstring like '(#$ . 5521)' and treated it | 2994 | /* read_list found a docstring like '(#$ . 5521)' and treated it |