public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] analyzer: fix ICE on assignment from STRING_CST when building path [PR100011]
@ 2021-04-10 20:27 David Malcolm
  0 siblings, 0 replies; only message in thread
From: David Malcolm @ 2021-04-10 20:27 UTC (permalink / raw)
  To: gcc-patches

Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
Pushed to trunk as r11-8117-gec633d3777bd71f7bde5e671b61ec18e5b7b43ea.

gcc/analyzer/ChangeLog:
	PR analyzer/100011
	* region-model.cc (region_model::on_assignment): Avoid NULL
	dereference if ctxt is NULL when assigning from a STRING_CST.

gcc/testsuite/ChangeLog:
	PR analyzer/100011
	* gcc.dg/analyzer/pr100011.c: New test.
---
 gcc/analyzer/region-model.cc             |  2 +-
 gcc/testsuite/gcc.dg/analyzer/pr100011.c | 16 ++++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.dg/analyzer/pr100011.c

diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc
index 2d3880bf8cc..c7038dd2d4b 100644
--- a/gcc/analyzer/region-model.cc
+++ b/gcc/analyzer/region-model.cc
@@ -726,7 +726,7 @@ region_model::on_assignment (const gassign *assign, region_model_context *ctxt)
 	   access will "inherit" the individual chars.  */
 	const svalue *rhs_sval = get_rvalue (rhs1, ctxt);
 	m_store.set_value (m_mgr->get_store_manager(), lhs_reg, rhs_sval,
-			   BK_default, ctxt->get_uncertainty ());
+			   BK_default, ctxt ? ctxt->get_uncertainty () : NULL);
       }
       break;
     }
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr100011.c b/gcc/testsuite/gcc.dg/analyzer/pr100011.c
new file mode 100644
index 00000000000..228cfdfeac7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/pr100011.c
@@ -0,0 +1,16 @@
+/* { dg-require-effective-target signal } */
+
+#include <stdlib.h>
+#include <signal.h>
+
+void terminate(int sig)
+{
+  char buf[64] = { 0 };
+  exit(1); /* { dg-warning "call to 'exit' from within signal handler" } */
+}
+
+int main(int argc, char **argv)
+{
+  signal(0, terminate); /* { dg-message "registering 'terminate' as signal handler" } */
+  return 0;
+}
-- 
2.26.2


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-04-10 20:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-10 20:27 [committed] analyzer: fix ICE on assignment from STRING_CST when building path [PR100011] David Malcolm

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).