From eb84665417392d14376924f295b4cf0139412d20 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Fri, 22 Oct 2004 19:48:43 +0000 Subject: [PATCH] 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 --- gcc/ChangeLog | 5 +++++ gcc/sbitmap.h | 23 +++++++++++++++-------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1e782274b87a..5fd6a3d1c4c1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2004-10-22 Kazu Hirata + + * sbitmap.h (EXECUTE_IF_SET_IN_SBITMAP): Don't access PTR + beyond its end. + 2004-10-22 Eric Christopher * config/rs6000/rs6000.c (setup_incoming_varargs): Align DFmode diff --git a/gcc/sbitmap.h b/gcc/sbitmap.h index e75e3b66df30..779a99611293 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)