Do not overrun array bounds.
This should fix a bug reported today by Olatunji Oluwabukunmi in
<http://mail.gnu.org/archive/html/bug-bison/2003-05/msg00004.html>.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
This program is free software; you can redistribute it and/or modify
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
This program is free software; you can redistribute it and/or modify
bitset_bindex i;
bitset_iterator iter;
bitset_bindex i;
bitset_iterator iter;
BITSET_FOR_EACH (iter, src, i, 0)
{
printf ("%ld ", i);
BITSET_FOR_EACH (iter, src, i, 0)
{
printf ("%ld ", i);
(ITER.num == BITSET_LIST_SIZE) \
&& (ITER.num = bitset_list (BSET, ITER.list, \
BITSET_LIST_SIZE, &ITER.next));) \
(ITER.num == BITSET_LIST_SIZE) \
&& (ITER.num = bitset_list (BSET, ITER.list, \
BITSET_LIST_SIZE, &ITER.next));) \
- for (ITER.i = 0; (BIT) = ITER.list[ITER.i], ITER.i < ITER.num; ITER.i++)
+ for (ITER.i = 0; \
+ ITER.i < ITER.num && ((BIT) = ITER.list[ITER.i], 1); \
+ ITER.i++)
/* Loop over all elements of BSET, in reverse order starting with
/* Loop over all elements of BSET, in reverse order starting with
bitset_bindex i;
bitset_iterator iter;
bitset_bindex i;
bitset_iterator iter;
BITSET_FOR_EACH_REVERSE (iter, src, i, 0)
{
printf ("%ld ", i);
BITSET_FOR_EACH_REVERSE (iter, src, i, 0)
{
printf ("%ld ", i);
(ITER.num == BITSET_LIST_SIZE) \
&& (ITER.num = bitset_list_reverse (BSET, ITER.list, \
BITSET_LIST_SIZE, &ITER.next));) \
(ITER.num == BITSET_LIST_SIZE) \
&& (ITER.num = bitset_list_reverse (BSET, ITER.list, \
BITSET_LIST_SIZE, &ITER.next));) \
- for (ITER.i = 0; (BIT) = ITER.list[ITER.i], ITER.i < ITER.num; ITER.i++)
+ for (ITER.i = 0; \
+ ITER.i < ITER.num && ((BIT) = ITER.list[ITER.i], 1); \
+ ITER.i++)
/* Define set operations in terms of logical operations. */
/* Define set operations in terms of logical operations. */