analyzer: fix member call on null seen with ubsan [PR97178]
authorDavid Malcolm <dmalcolm@redhat.com>
Wed, 23 Sep 2020 15:18:43 +0000 (11:18 -0400)
committerDavid Malcolm <dmalcolm@redhat.com>
Wed, 23 Sep 2020 17:27:48 +0000 (13:27 -0400)
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.

gcc/analyzer/engine.cc
gcc/analyzer/program-state.cc
gcc/analyzer/program-state.h

index 437429798f24159fe629ada5068828aecee5a38c..b36c1988406a614de621d791a2b05b00aed60ada 100644 (file)
@@ -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);
 
index 83a6e5b081e6ee607b173f27a2920f581071f235..188fec0241861b5e41b537a53f57e1f9ef16e556 100644 (file)
@@ -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);
index a52fbeb2e3eb37a1e7d5bc661a10aef34839f109..094d25626568500af97bc31d4e0e1f1f19142121 100644 (file)
@@ -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)
   {
   }