aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorPaul Eggert2013-11-20 22:46:59 -0800
committerPaul Eggert2013-11-20 22:46:59 -0800
commit75360f19c3994ab7a532124b7f5eb92bfe7c82ed (patch)
treeed6a415b319a37144d63bdfe967daff766f4e044 /src/alloc.c
parentd1a6bccc995f7e1e9d22a386e1aac0d7c888ff18 (diff)
downloademacs-75360f19c3994ab7a532124b7f5eb92bfe7c82ed.tar.gz
emacs-75360f19c3994ab7a532124b7f5eb92bfe7c82ed.zip
Fix recently introduced bool vector overrun.
This was due to an optimization that went awry. Reported by Glenn Morris in <http://lists.gnu.org/archive/html/emacs-devel/2013-11/msg00622.html>. * alloc.c (make_uninit_bool_vector): Don't allocate a dummy word for empty vectors, undoing the 2013-11-18 change. * data.c (bool_vector_binop_driver): Rely on this. Fix bug that occasionally overran the destination. * lisp.h (struct Lisp_Bool_vector): Document this.
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 7c560fd0f0d..283bc613c82 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -2066,8 +2066,7 @@ Lisp_Object
2066make_uninit_bool_vector (EMACS_INT nbits) 2066make_uninit_bool_vector (EMACS_INT nbits)
2067{ 2067{
2068 Lisp_Object val; 2068 Lisp_Object val;
2069 EMACS_INT words0 = bool_vector_words (nbits); 2069 EMACS_INT words = bool_vector_words (nbits);
2070 EMACS_INT words = words0 + !words0; /* Allocate at least one word. */
2071 EMACS_INT word_bytes = words * sizeof (bits_word); 2070 EMACS_INT word_bytes = words * sizeof (bits_word);
2072 EMACS_INT needed_elements = ((bool_header_size - header_size + word_bytes 2071 EMACS_INT needed_elements = ((bool_header_size - header_size + word_bytes
2073 + word_size - 1) 2072 + word_size - 1)
@@ -2078,9 +2077,9 @@ make_uninit_bool_vector (EMACS_INT nbits)
2078 XSETPVECTYPESIZE (XVECTOR (val), PVEC_BOOL_VECTOR, 0, 0); 2077 XSETPVECTYPESIZE (XVECTOR (val), PVEC_BOOL_VECTOR, 0, 0);
2079 p->size = nbits; 2078 p->size = nbits;
2080 2079
2081 /* Clear padding at the end. If NBITS != 0 this initializes more 2080 /* Clear padding at the end. */
2082 than it needs to, but that's OK. */ 2081 if (words)
2083 p->data[words - 1] = 0; 2082 p->data[words - 1] = 0;
2084 2083
2085 return val; 2084 return val;
2086} 2085}