From: Paul Eggert Date: Wed, 18 Jul 2012 17:29:34 +0000 (-0700) Subject: * alloc.c (Fmake_bool_vector): Fix off-by-8 bug X-Git-Tag: emacs-24.2.90~1138 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=837131548b13935cc7a2cbb7114bfb0ee44eae76;p=emacs.git * alloc.c (Fmake_bool_vector): Fix off-by-8 bug when invoking (make-bool-vector N t) and N is a positive multiple of 8 -- the last 8 bits were mistakenly cleared. --- diff --git a/src/ChangeLog b/src/ChangeLog index 3f12159d169..d202e1d3f38 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,9 @@ 2012-07-18 Paul Eggert + * alloc.c (Fmake_bool_vector): Fix off-by-8 bug + when invoking (make-bool-vector N t) and N is a positive + multiple of 8 -- the last 8 bits were mistakenly cleared. + Remove some struct layout assumptions in bool vectors. * alloc.c (bool_header_size): New constant. (header_size, word_size): Move earlier, as they're now used earlier. diff --git a/src/alloc.c b/src/alloc.c index 29aabdd4616..a6980e867a7 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -2389,7 +2389,7 @@ LENGTH must be a number. INIT matters only in whether it is t or nil. */) /* Clear any extraneous bits in the last byte. */ p->data[length_in_chars - 1] - &= (1 << (XINT (length) % BOOL_VECTOR_BITS_PER_CHAR)) - 1; + &= (1 << ((XFASTINT (length) - 1) % BOOL_VECTOR_BITS_PER_CHAR + 1)) - 1; } return val;