summaryrefslogtreecommitdiff
path: root/meta-linaro-toolchain/recipes-devtools/gcc/gcc-4.7/avoid-oob-array-access.patch
blob: 4ba707d0b21f7805138d2fbca63f89dfcc7e2586 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
Upstream-Status: Backport

See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56308

From 1e37e371d2cca3549b71a247bf79778aa1a9e1c4 Mon Sep 17 00:00:00 2001
From: rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Fri, 21 Sep 2012 10:08:35 +0000
Subject: [PATCH] 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@191605 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog | 9 +++++++++
 gcc/ira-int.h | 9 +++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/gcc/ira-int.h b/gcc/ira-int.h
index 9faabb5..771a368 100644
--- a/gcc/ira-int.h
+++ b/gcc/ira-int.h
@@ -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
-- 
1.8.2.2