Commit b4e50fa0 authored by Paul Eggert's avatar Paul Eggert
Browse files

* fns.c (Ffillarray): Don't assume bool vector size fits in 'int'.

parent c0c1ee9f
2011-06-18 Paul Eggert <eggert@cs.ucla.edu> 2011-06-18 Paul Eggert <eggert@cs.ucla.edu>
* fns.c (Ffillarray): Don't assume bool vector size fits in 'int'.
* alloc.c (Fmake_bool_vector): Avoid unnecessary multiplication. * alloc.c (Fmake_bool_vector): Avoid unnecessary multiplication.
* fns.c (concat): Catch string overflow earlier. * fns.c (concat): Catch string overflow earlier.
......
...@@ -2188,19 +2188,17 @@ ARRAY is a vector, string, char-table, or bool-vector. */) ...@@ -2188,19 +2188,17 @@ ARRAY is a vector, string, char-table, or bool-vector. */)
else if (BOOL_VECTOR_P (array)) else if (BOOL_VECTOR_P (array))
{ {
register unsigned char *p = XBOOL_VECTOR (array)->data; register unsigned char *p = XBOOL_VECTOR (array)->data;
int size_in_chars EMACS_INT size = XBOOL_VECTOR (array)->size;
= ((XBOOL_VECTOR (array)->size + BOOL_VECTOR_BITS_PER_CHAR - 1) EMACS_INT size_in_chars
= ((size + BOOL_VECTOR_BITS_PER_CHAR - 1)
/ BOOL_VECTOR_BITS_PER_CHAR); / BOOL_VECTOR_BITS_PER_CHAR);
charval = (! NILP (item) ? -1 : 0); if (size_in_chars)
for (idx = 0; idx < size_in_chars - 1; idx++)
p[idx] = charval;
if (idx < size_in_chars)
{ {
/* Mask out bits beyond the vector size. */ memset (p, ! NILP (item) ? -1 : 0, size_in_chars);
if (XBOOL_VECTOR (array)->size % BOOL_VECTOR_BITS_PER_CHAR)
charval &= (1 << (XBOOL_VECTOR (array)->size % BOOL_VECTOR_BITS_PER_CHAR)) - 1; /* Clear any extraneous bits in the last byte. */
p[idx] = charval; p[size_in_chars - 1] &= (1 << (size % BOOL_VECTOR_BITS_PER_CHAR)) - 1;
} }
} }
else else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment