re PR sanitizer/79558 (ICE: Segfault in ubsan_type_descriptor, at ubsan.c:412)

PR sanitizer/79558
	* ubsan.c (ubsan_type_descriptor): Check if TYPE_MAX_VALUE is null.

	* c-c++-common/ubsan/bounds-14.c: New test.

From-SVN: r245605
This commit is contained in:
Marek Polacek 2017-02-20 15:50:23 +00:00 committed by Marek Polacek
parent 80480ceee9
commit 85ade8d640
4 changed files with 22 additions and 1 deletions

View File

@ -3,6 +3,9 @@
PR middle-end/79537
* gimplify.c (gimplify_expr): Handle unused *&&L;.
PR sanitizer/79558
* ubsan.c (ubsan_type_descriptor): Check if TYPE_MAX_VALUE is null.
2017-02-20 Jakub Jelinek <jakub@redhat.com>
PR target/79568

View File

@ -3,6 +3,9 @@
PR middle-end/79537
* gcc.dg/comp-goto-4.c: New test.
PR sanitizer/79558
* c-c++-common/ubsan/bounds-14.c: New test.
2017-02-20 Jakub Jelinek <jakub@redhat.com>
PR target/79568

View File

@ -0,0 +1,13 @@
/* PR sanitizer/79558 */
/* { dg-do compile } */
/* { dg-options "-fsanitize=bounds" } */
void
fn1 (int n)
{
int i, j;
int x[2][0];
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
x[i][j] = 5;
}

View File

@ -409,7 +409,9 @@ ubsan_type_descriptor (tree type, enum ubsan_print_style pstyle)
{
pp_left_bracket (&pretty_name);
tree dom = TYPE_DOMAIN (t);
if (dom && TREE_CODE (TYPE_MAX_VALUE (dom)) == INTEGER_CST)
if (dom != NULL_TREE
&& TYPE_MAX_VALUE (dom) != NULL_TREE
&& TREE_CODE (TYPE_MAX_VALUE (dom)) == INTEGER_CST)
{
if (tree_fits_uhwi_p (TYPE_MAX_VALUE (dom))
&& tree_to_uhwi (TYPE_MAX_VALUE (dom)) + 1 != 0)