diff options
author | David Malcolm <dmalcolm@redhat.com> | 2020-09-23 11:18:43 -0400 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2020-09-23 13:27:48 -0400 |
commit | f65ebb5210e2fded0f7b339219685f4480124f0c (patch) | |
tree | cd10f995a2f072130320123fb13ec6015bc7bc3a /gcc | |
parent | 65c9878641cbe0ed898aa7047b7b994e9d4a5bb1 (diff) | |
download | gcc-f65ebb5210e2fded0f7b339219685f4480124f0c.zip gcc-f65ebb5210e2fded0f7b339219685f4480124f0c.tar.gz gcc-f65ebb5210e2fded0f7b339219685f4480124f0c.tar.bz2 |
analyzer: fix member call on null seen with ubsan [PR97178]
gcc/analyzer/ChangeLog:
PR analyzer/97178
* engine.cc (impl_run_checkers): Update for change to ext_state
ctor.
* program-state.cc (selftest::test_sm_state_map): Pass an engine
instance to ext_state ctor.
(selftest::test_program_state_1): Likewise.
(selftest::test_program_state_2): Likewise.
(selftest::test_program_state_merging): Likewise.
(selftest::test_program_state_merging_2): Likewise.
* program-state.h (extrinsic_state::extrinsic_state): Remove NULL
default value for "eng" param.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/analyzer/engine.cc | 2 | ||||
-rw-r--r-- | gcc/analyzer/program-state.cc | 12 | ||||
-rw-r--r-- | gcc/analyzer/program-state.h | 4 |
3 files changed, 10 insertions, 8 deletions
diff --git a/gcc/analyzer/engine.cc b/gcc/analyzer/engine.cc index 4374297..b36c198 100644 --- a/gcc/analyzer/engine.cc +++ b/gcc/analyzer/engine.cc @@ -4464,7 +4464,7 @@ impl_run_checkers (logger *logger) } /* Extrinsic state shared by nodes in the graph. */ - const extrinsic_state ext_state (checkers, logger, &eng); + const extrinsic_state ext_state (checkers, &eng, logger); const analysis_plan plan (sg, logger); diff --git a/gcc/analyzer/program-state.cc b/gcc/analyzer/program-state.cc index 83a6e5b..188fec0 100644 --- a/gcc/analyzer/program-state.cc +++ b/gcc/analyzer/program-state.cc @@ -1140,7 +1140,8 @@ test_sm_state_map () state_machine *sm = make_malloc_state_machine (NULL); auto_delete_vec <state_machine> checkers; checkers.safe_push (sm); - extrinsic_state ext_state (checkers); + engine eng; + extrinsic_state ext_state (checkers, &eng); state_machine::state_t start = sm->get_start_state (); /* Test setting states on svalue_id instances directly. */ @@ -1272,7 +1273,7 @@ test_program_state_1 () checkers.safe_push (sm); engine eng; - extrinsic_state ext_state (checkers, NULL, &eng); + extrinsic_state ext_state (checkers, &eng); region_model_manager *mgr = eng.get_model_manager (); program_state s (ext_state); region_model *model = s.m_region_model; @@ -1301,7 +1302,7 @@ test_program_state_2 () auto_delete_vec <state_machine> checkers; engine eng; - extrinsic_state ext_state (checkers, NULL, &eng); + extrinsic_state ext_state (checkers, &eng); program_state s (ext_state); region_model *model = s.m_region_model; @@ -1324,7 +1325,7 @@ test_program_state_merging () auto_delete_vec <state_machine> checkers; checkers.safe_push (make_malloc_state_machine (NULL)); engine eng; - extrinsic_state ext_state (checkers, NULL, &eng); + extrinsic_state ext_state (checkers, &eng); region_model_manager *mgr = eng.get_model_manager (); program_state s0 (ext_state); @@ -1389,7 +1390,8 @@ test_program_state_merging_2 () program_point point (program_point::origin ()); auto_delete_vec <state_machine> checkers; checkers.safe_push (make_signal_state_machine (NULL)); - extrinsic_state ext_state (checkers); + engine eng; + extrinsic_state ext_state (checkers, &eng); const state_machine::state test_state_0 ("test state 0", 0); const state_machine::state test_state_1 ("test state 1", 1); diff --git a/gcc/analyzer/program-state.h b/gcc/analyzer/program-state.h index a52fbeb..094d256 100644 --- a/gcc/analyzer/program-state.h +++ b/gcc/analyzer/program-state.h @@ -29,8 +29,8 @@ class extrinsic_state { public: extrinsic_state (auto_delete_vec <state_machine> &checkers, - logger *logger = NULL, - engine *eng = NULL) + engine *eng, + logger *logger = NULL) : m_checkers (checkers), m_logger (logger), m_engine (eng) { } |