OSDN Git Service

2012-09-21 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 21 Sep 2012 10:08:35 +0000 (10:08 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 21 Sep 2012 10:08:35 +0000 (10:08 +0000)
PR middle-end/54638
Backport from mainline
2012-04-19  Richard Guenther  <rguenther@suse.de>

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

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@191605 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/ira-int.h

index df7c0a8..5c52957 100644 (file)
@@ -1,3 +1,12 @@
+2012-09-21  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/54638
+       Backport from mainline
+       2012-04-19  Richard Guenther  <rguenther@suse.de>
+
+       * ira-int.h (ira_allocno_object_iter_cond): Avoid out-of-bound
+       array access.
+
 2012-09-20  Joseph Myers  <joseph@codesourcery.com>
 
        PR c/54552
index 9faabb5..771a368 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