aboutsummaryrefslogtreecommitdiff
path: root/gcc/analyzer/engine.cc
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2022-05-11 17:24:42 -0400
committerDavid Malcolm <dmalcolm@redhat.com>2022-05-11 17:24:42 -0400
commit99988b0e8b57b360719ce334fb6d278cb6722bec (patch)
treeef9eceddeae90971712f6d181ab0def3561b9c8e /gcc/analyzer/engine.cc
parent25addf8352e590fab926e9d16c2cd4a7ea0963b9 (diff)
downloadgcc-99988b0e8b57b360719ce334fb6d278cb6722bec.zip
gcc-99988b0e8b57b360719ce334fb6d278cb6722bec.tar.gz
gcc-99988b0e8b57b360719ce334fb6d278cb6722bec.tar.bz2
analyzer: fix memory leaks
These leaks all relate to logging within -fdump-analyzer[-stderr] or are one-time leaks; seen with valgrind. gcc/analyzer/ChangeLog: * checker-path.cc (state_change_event::get_desc): Call maybe_free on label_text temporaries. * diagnostic-manager.cc (diagnostic_manager::prune_for_sm_diagnostic): Likewise. * engine.cc (exploded_graph::~exploded_graph): Fix leak of m_per_point_data and m_per_call_string_data values. Simplify cleanup of m_per_function_stats and m_per_point_data values. (feasibility_state::maybe_update_for_edge): Fix leak of result of superedge::get_description. * region-model-manager.cc (region_model_manager::~region_model_manager): Move cleanup of m_setjmp_values to match the ordering of the fields within region_model_manager. Fix leak of values within m_repeated_values_map, m_bits_within_values_map, m_asm_output_values_map, and m_const_fn_result_values_map. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Diffstat (limited to 'gcc/analyzer/engine.cc')
-rw-r--r--gcc/analyzer/engine.cc29
1 files changed, 16 insertions, 13 deletions
diff --git a/gcc/analyzer/engine.cc b/gcc/analyzer/engine.cc
index e43406e..0332932 100644
--- a/gcc/analyzer/engine.cc
+++ b/gcc/analyzer/engine.cc
@@ -2340,15 +2340,14 @@ exploded_graph::exploded_graph (const supergraph &sg, logger *logger,
exploded_graph::~exploded_graph ()
{
- for (function_stat_map_t::iterator iter = m_per_function_stats.begin ();
- iter != m_per_function_stats.end ();
- ++iter)
- delete (*iter).second;
-
- for (point_map_t::iterator iter = m_per_point_data.begin ();
- iter != m_per_point_data.end ();
- ++iter)
- delete (*iter).second;
+ for (auto iter : m_per_point_data)
+ delete iter.second;
+ for (auto iter : m_per_function_data)
+ delete iter.second;
+ for (auto iter : m_per_function_stats)
+ delete iter.second;
+ for (auto iter : m_per_call_string_data)
+ delete iter.second;
}
/* Subroutine for use when implementing __attribute__((tainted_args))
@@ -4538,10 +4537,14 @@ feasibility_state::maybe_update_for_edge (logger *logger,
if (sedge)
{
if (logger)
- logger->log (" sedge: SN:%i -> SN:%i %s",
- sedge->m_src->m_index,
- sedge->m_dest->m_index,
- sedge->get_description (false));
+ {
+ char *desc = sedge->get_description (false);
+ logger->log (" sedge: SN:%i -> SN:%i %s",
+ sedge->m_src->m_index,
+ sedge->m_dest->m_index,
+ desc);
+ free (desc);
+ }
const gimple *last_stmt = src_point.get_supernode ()->get_last_stmt ();
if (!m_model.maybe_update_for_edge (*sedge, last_stmt, NULL, out_rc))