From ba355de014b75ed104da4777f909db70d62f2357 Mon Sep 17 00:00:00 2001 From: Barry O'Reilly Date: Wed, 25 Sep 2013 23:46:47 -0400 Subject: [PATCH] Signal error when reading an empty byte-code object (Bug#15405) * lread.c (read1): signal error * alloc.c (make_byte_code): eassert header size (sweep_vectors): change an int to size_t --- src/ChangeLog | 7 +++++++ src/alloc.c | 4 +++- src/lread.c | 5 ++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 3f0c4196afd..a6774e30b0c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2013-09-26 Barry O'Reilly + + Signal error when reading an empty byte-code object (Bug#15405) + * lread.c (read1): signal error + * alloc.c (make_byte_code): eassert header size + (sweep_vectors): change an int to size_t + 2013-09-24 Paul Eggert * dispnew.c (clear_glyph_row, copy_row_except_pointers): Use enums diff --git a/src/alloc.c b/src/alloc.c index ca21ba2469b..2d9828ffa79 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -2889,7 +2889,7 @@ sweep_vectors (void) free_this_block = 1; else { - int tmp; + size_t tmp; SETUP_ON_FREE_LIST (vector, total_bytes, tmp); } } @@ -3132,6 +3132,8 @@ usage: (vector &rest OBJECTS) */) void make_byte_code (struct Lisp_Vector *v) { + /* Don't allow the global zero_vector to become a byte code object. */ + eassert(0 < v->header.size); if (v->header.size > 1 && STRINGP (v->u.contents[1]) && STRING_MULTIBYTE (v->u.contents[1])) /* BYTECODE-STRING must have been produced by Emacs 20.2 or the diff --git a/src/lread.c b/src/lread.c index 017dfcb11a5..fe2b92a34b3 100644 --- a/src/lread.c +++ b/src/lread.c @@ -2597,7 +2597,10 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list) build them using function calls. */ Lisp_Object tmp; tmp = read_vector (readcharfun, 1); - make_byte_code (XVECTOR (tmp)); + struct Lisp_Vector* vec = XVECTOR (tmp); + if (vec->header.size==0) + invalid_syntax ("Empty byte-code object"); + make_byte_code (vec); return tmp; } if (c == '(') -- 2.39.2