re PR sanitizer/81223 (ICE in instrument_null at gcc/ubsan.c:1230)

PR sanitizer/81223
	* ubsan.c (instrument_null): Check get_base_address's result for null.

	* gcc.dg/ubsan/pr81223.c: New test.

From-SVN: r249687
This commit is contained in:
Marek Polacek 2017-06-27 11:38:31 +00:00 committed by Marek Polacek
parent 1e7df2e63a
commit 786c6d10af
4 changed files with 24 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2017-06-27 Marek Polacek <polacek@redhat.com>
PR sanitizer/81223
* ubsan.c (instrument_null): Check get_base_address's result for null.
2017-06-27 Marc Glisse <marc.glisse@inria.fr> 2017-06-27 Marc Glisse <marc.glisse@inria.fr>
* match.pd ((A+-B)+(C-A), (A+B)-(A-C)): New transformations. * match.pd ((A+-B)+(C-A), (A+B)-(A-C)): New transformations.

View File

@ -1,3 +1,8 @@
2017-06-27 Marek Polacek <polacek@redhat.com>
PR sanitizer/81223
* gcc.dg/ubsan/pr81223.c: New test.
2017-06-27 Marc Glisse <marc.glisse@inria.fr> 2017-06-27 Marc Glisse <marc.glisse@inria.fr>
* gcc.dg/tree-ssa/assoc-1.c: New file. * gcc.dg/tree-ssa/assoc-1.c: New file.

View File

@ -0,0 +1,12 @@
/* PR sanitizer/81223 */
/* { dg-do compile } */
/* { dg-options "-fsanitize=undefined" } */
void bar ();
void
foo (int x)
{
struct S { char a[x]; } v;
bar (v);
}

View File

@ -1228,7 +1228,8 @@ instrument_null (gimple_stmt_iterator gsi, tree t, bool is_lhs)
if (TREE_CODE (t) == ADDR_EXPR) if (TREE_CODE (t) == ADDR_EXPR)
t = TREE_OPERAND (t, 0); t = TREE_OPERAND (t, 0);
tree base = get_base_address (t); tree base = get_base_address (t);
if (TREE_CODE (base) == MEM_REF if (base != NULL_TREE
&& TREE_CODE (base) == MEM_REF
&& TREE_CODE (TREE_OPERAND (base, 0)) == SSA_NAME) && TREE_CODE (TREE_OPERAND (base, 0)) == SSA_NAME)
instrument_mem_ref (t, base, &gsi, is_lhs); instrument_mem_ref (t, base, &gsi, is_lhs);
} }