public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Ilya Enkovich <enkovich.gnu@gmail.com>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH, PR67405, committed] Avoid NULL pointer dereference
Date: Tue, 01 Sep 2015 15:04:00 -0000	[thread overview]
Message-ID: <20150901143909.GB55610@msticlxl57.ims.intel.com> (raw)

Hi,

This fixes an ICE by adding a NULL check.  Bootstrapped and regtested for x86_64-unknown-linux-gnu.  Applied to trunk.  Does this need to be ported to gcc-5-branch?

Thanks,
Ilya
--
gcc/

2015-09-01  Ilya Enkovich  <enkovich.gnu@gmail.com>

	PR target/67405
	* tree-chkp.c (chkp_find_bound_slots_1): Add NULL check.

gcc/testsuite/

2015-09-01  Ilya Enkovich  <enkovich.gnu@gmail.com>

	PR target/67405
	* g++.dg/pr67405.C: New test.


diff --git a/gcc/testsuite/g++.dg/pr67405.C b/gcc/testsuite/g++.dg/pr67405.C
new file mode 100644
index 0000000..5055921
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr67405.C
@@ -0,0 +1,11 @@
+// { dg-do compile }
+
+struct S
+{
+  S f; // { dg-error "incomplete type" }
+};
+
+void
+fn1 (S p1)
+{
+}
diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c
index 8c1b48c..2489abb 100644
--- a/gcc/tree-chkp.c
+++ b/gcc/tree-chkp.c
@@ -1667,8 +1667,9 @@ chkp_find_bound_slots_1 (const_tree type, bitmap have_bound,
       for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
 	if (TREE_CODE (field) == FIELD_DECL)
 	  {
-	    HOST_WIDE_INT field_offs
-	      = TREE_INT_CST_LOW (DECL_FIELD_BIT_OFFSET (field));
+	    HOST_WIDE_INT field_offs = 0;
+	    if (DECL_FIELD_BIT_OFFSET (field))
+	      field_offs += TREE_INT_CST_LOW (DECL_FIELD_BIT_OFFSET (field));
 	    if (DECL_FIELD_OFFSET (field))
 	      field_offs += TREE_INT_CST_LOW (DECL_FIELD_OFFSET (field)) * 8;
 	    chkp_find_bound_slots_1 (TREE_TYPE (field), have_bound,

             reply	other threads:[~2015-09-01 15:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-01 15:04 Ilya Enkovich [this message]
2015-09-02 12:35 ` Richard Biener
2015-09-02 12:51   ` Ilya Enkovich
2015-09-02 13:25     ` Richard Biener
2015-09-07 12:48   ` Ilya Enkovich
2015-09-13 14:46     ` Richard Biener
2015-09-15  9:30       ` Ilya Enkovich
2015-09-15 10:34         ` Richard Biener
2015-09-15 11:10           ` Ilya Enkovich
2015-09-24 15:13             ` Ilya Enkovich
2015-09-24 15:18               ` Richard Biener

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150901143909.GB55610@msticlxl57.ims.intel.com \
    --to=enkovich.gnu@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).