summaryrefslogtreecommitdiff
path: root/gcc/ubsan.c
diff options
context:
space:
mode:
authormpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4>2014-11-19 14:32:02 +0000
committermpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4>2014-11-19 14:32:02 +0000
commitc3151cc59b3ee0b3d2a2e2ed54880f66cab77c7d (patch)
treecb18d477dddc969d4782f2d7ef4c4f046aef8e81 /gcc/ubsan.c
parentdca859ebc5b5832aefc5c3dcea1cfe5497cf8012 (diff)
downloadgcc-c3151cc59b3ee0b3d2a2e2ed54880f66cab77c7d.tar.gz
PR sanitizer/63690
* ubsan.c (instrument_object_size): Check for MEM_REF. * gcc.dg/ubsan/pr63690.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@217778 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ubsan.c')
-rw-r--r--gcc/ubsan.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/gcc/ubsan.c b/gcc/ubsan.c
index 7d1e341812c..ad5665ff047 100644
--- a/gcc/ubsan.c
+++ b/gcc/ubsan.c
@@ -1539,7 +1539,13 @@ instrument_object_size (gimple_stmt_iterator *gsi, bool is_lhs)
return;
bool decl_p = DECL_P (inner);
- tree base = decl_p ? inner : TREE_OPERAND (inner, 0);
+ tree base;
+ if (decl_p)
+ base = inner;
+ else if (TREE_CODE (inner) == MEM_REF)
+ base = TREE_OPERAND (inner, 0);
+ else
+ return;
tree ptr = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (t)), t);
while (TREE_CODE (base) == SSA_NAME)