summaryrefslogtreecommitdiff
path: root/gcc/ubsan.c
diff options
context:
space:
mode:
authorDenis Khalikov <d.khalikov@partner.samsung.com>2017-04-13 14:52:23 +0000
committerMaxim Ostapenko <chefmax@gcc.gnu.org>2017-04-13 17:52:23 +0300
commitabac4c3400842a20e3f09714134377ae8133ee95 (patch)
tree5b7d0a266ba8621da1826fad0f8009fa4d0b9fc4 /gcc/ubsan.c
parent3535a0fb6f43d4d985f3bbf9699bc3eea4fb64b0 (diff)
re PR sanitizer/80414 ([UBSAN] segfault with -fsanitize=undefined)
PR sanitizer/80414 * ubsan.c (ubsan_expand_bounds_ifn): Pass original index to ubsan_encode_value. * c-c++-common/ubsan/bounds-15.c: New test. From-SVN: r246909
Diffstat (limited to 'gcc/ubsan.c')
-rw-r--r--gcc/ubsan.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/gcc/ubsan.c b/gcc/ubsan.c
index c01d63318c2..4159cc5f6f9 100644
--- a/gcc/ubsan.c
+++ b/gcc/ubsan.c
@@ -673,7 +673,7 @@ ubsan_expand_bounds_ifn (gimple_stmt_iterator *gsi)
/* Pick up the arguments of the UBSAN_BOUNDS call. */
tree type = TREE_TYPE (TREE_TYPE (gimple_call_arg (stmt, 0)));
tree index = gimple_call_arg (stmt, 1);
- tree orig_index_type = TREE_TYPE (index);
+ tree orig_index = index;
tree bound = gimple_call_arg (stmt, 2);
gimple_stmt_iterator gsi_orig = *gsi;
@@ -700,7 +700,7 @@ ubsan_expand_bounds_ifn (gimple_stmt_iterator *gsi)
tree data
= ubsan_create_data ("__ubsan_out_of_bounds_data", 1, &loc,
ubsan_type_descriptor (type, UBSAN_PRINT_ARRAY),
- ubsan_type_descriptor (orig_index_type),
+ ubsan_type_descriptor (TREE_TYPE (orig_index)),
NULL_TREE, NULL_TREE);
data = build_fold_addr_expr_loc (loc, data);
enum built_in_function bcode
@@ -708,9 +708,9 @@ ubsan_expand_bounds_ifn (gimple_stmt_iterator *gsi)
? BUILT_IN_UBSAN_HANDLE_OUT_OF_BOUNDS
: BUILT_IN_UBSAN_HANDLE_OUT_OF_BOUNDS_ABORT;
tree fn = builtin_decl_explicit (bcode);
- tree val = force_gimple_operand_gsi (gsi, ubsan_encode_value (index),
- true, NULL_TREE, true,
- GSI_SAME_STMT);
+ tree val
+ = force_gimple_operand_gsi (gsi, ubsan_encode_value (orig_index), true,
+ NULL_TREE, true, GSI_SAME_STMT);
g = gimple_build_call (fn, 2, data, val);
}
gimple_set_location (g, loc);