diff options
author | Kazu Hirata <kazu@cs.umass.edu> | 2004-10-22 19:48:43 +0000 |
---|---|---|
committer | Kazu Hirata <kazu@gcc.gnu.org> | 2004-10-22 19:48:43 +0000 |
commit | eb84665417392d14376924f295b4cf0139412d20 (patch) | |
tree | db8ff49ee7fb6185b65238bded5ea7be9e7671f7 /gcc/sbitmap.h | |
parent | 94ff898d42eb5f11724e951d7662cf777f1abc44 (diff) | |
download | gcc-eb84665417392d14376924f295b4cf0139412d20.tar.gz |
sbitmap.h (EXECUTE_IF_SET_IN_SBITMAP): Don't access PTR beyond its end.
* sbitmap.h (EXECUTE_IF_SET_IN_SBITMAP): Don't access PTR
beyond its end.
From-SVN: r89475
Diffstat (limited to 'gcc/sbitmap.h')
-rw-r--r-- | gcc/sbitmap.h | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/gcc/sbitmap.h b/gcc/sbitmap.h index e75e3b66df3..779a9961129 100644 --- a/gcc/sbitmap.h +++ b/gcc/sbitmap.h @@ -62,19 +62,26 @@ do { \ unsigned int bit_num_ = (MIN) % (unsigned int) SBITMAP_ELT_BITS; \ unsigned int size_ = (SBITMAP)->size; \ SBITMAP_ELT_TYPE *ptr_ = (SBITMAP)->elms; \ - SBITMAP_ELT_TYPE word_ = ptr_[word_num_] >> bit_num_; \ + SBITMAP_ELT_TYPE word_; \ \ - for (; \ - word_num_ < size_; \ - word_num_++, bit_num_ = 0, word_ = ptr_[word_num_]) \ + if (word_num_ < size_) \ { \ - for (; word_ != 0; word_ >>= 1, bit_num_++) \ + word_ = ptr_[word_num_] >> bit_num_; \ + \ + while (1) \ { \ - if ((word_ & 1) != 0) \ + for (; word_ != 0; word_ >>= 1, bit_num_++) \ { \ - (N) = word_num_ * SBITMAP_ELT_BITS + bit_num_; \ - CODE; \ + if ((word_ & 1) != 0) \ + { \ + (N) = word_num_ * SBITMAP_ELT_BITS + bit_num_; \ + CODE; \ + } \ } \ + word_num_++; \ + if (word_num_ >= size_) \ + break; \ + bit_num_ = 0, word_ = ptr_[word_num_]; \ } \ } \ } while (0) |