analyzer: fix ICE on assignment from STRING_CST when building path [PR100011]

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.
This commit is contained in:
David Malcolm 2021-04-10 16:23:23 -04:00
parent 9f7d77bd6d
commit ec633d3777
2 changed files with 17 additions and 1 deletions

View File

@ -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;
}

View File

@ -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;
}