]> git.eshelyaron.com Git - emacs.git/commitdiff
* alloc.c (Fmake_bool_vector): Fix off-by-8 bug
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 18 Jul 2012 17:29:34 +0000 (10:29 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 18 Jul 2012 17:29:34 +0000 (10:29 -0700)
when invoking (make-bool-vector N t) and N is a positive
multiple of 8 -- the last 8 bits were mistakenly cleared.

src/ChangeLog
src/alloc.c

index 3f12159d169b9fa93671712920f5739b2f4db5ca..d202e1d3f38ab25c541637c05ec00aec27c27688 100644 (file)
@@ -1,5 +1,9 @@
 2012-07-18  Paul Eggert  <eggert@cs.ucla.edu>
 
+       * 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.
index 29aabdd461675e7da0d5593c6804b6f139c8b7e5..a6980e867a77cd6ced2f85e09d7e84423acf40bb 100644 (file)
@@ -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;