]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ira-int.h (ira_allocno_object_iter_cond): Avoid out-of-bound array access.
authorRichard Guenther <rguenther@suse.de>
Thu, 19 Apr 2012 12:44:07 +0000 (12:44 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 19 Apr 2012 12:44:07 +0000 (12:44 +0000)
2012-04-19  Richard Guenther  <rguenther@suse.de>

* ira-int.h (ira_allocno_object_iter_cond): Avoid out-of-bound
array access.

From-SVN: r186590

gcc/ChangeLog
gcc/ira-int.h

index 086b8136f50076adff566ed31cc27d78c12dada5..5d127ca9e876ec96eae7eee672763b34d9398a56 100644 (file)
@@ -1,3 +1,8 @@
+2012-04-19  Richard Guenther  <rguenther@suse.de>
+
+       * ira-int.h (ira_allocno_object_iter_cond): Avoid out-of-bound
+       array access.
+
 2012-04-19  Georg-Johann Lay  <avr@gjlay.de>
 
        PR target/53033
index 24976d0418cceefc3054190ca6a99bf2ac16e176..5db2ccc268c4163bf8906435dd3acc98405c4b60 100644 (file)
@@ -1138,8 +1138,13 @@ static inline bool
 ira_allocno_object_iter_cond (ira_allocno_object_iterator *i, ira_allocno_t a,
                              ira_object_t *o)
 {
-  *o = ALLOCNO_OBJECT (a, i->n);
-  return i->n++ < ALLOCNO_NUM_OBJECTS (a);
+  int n = i->n++;
+  if (n < ALLOCNO_NUM_OBJECTS (a))
+    {
+      *o = ALLOCNO_OBJECT (a, n);
+      return true;
+    }
+  return false;
 }
 
 /* Loop over all objects associated with allocno A.  In each