From 0c15457a497d50e5e9585c68f53d4fecf7b525ac Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Wed, 8 Jul 2020 15:49:18 -0400 Subject: [PATCH 292/315] FIXME: fix false leak in gzio.c --- gcc/analyzer/region-model2-reachability.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/gcc/analyzer/region-model2-reachability.cc b/gcc/analyzer/region-model2-reachability.cc index 1319ccafbca..337850f523b 100644 --- a/gcc/analyzer/region-model2-reachability.cc +++ b/gcc/analyzer/region-model2-reachability.cc @@ -100,6 +100,23 @@ reachable_region2s::init_cluster (const region2 *base_reg) as mutable (and traverse what they currently point to). */ if (m_store->escaped_p (base_reg)) add (base_reg, true); + + /* If BASE_REG is *INIT_VAL(REG) for some other REG, see if REG is + unbound and untouched. If so, then add BASE_REG as a root. */ + if (const symbolic_region2 *sym_reg = base_reg->dyn_cast_symbolic_region2 ()) + { + const svalue2 *ptr = sym_reg->get_pointer (); + if (const initial_svalue2 *init_sval = ptr->dyn_cast_initial_svalue2 ()) + { + const region2 *init_sval_reg = init_sval->get_region (); + const region2 *other_base_reg = init_sval_reg->get_base_region (); + const binding_cluster2 *other_cluster + = m_store->get_cluster (other_base_reg); + if (other_cluster == NULL + || !other_cluster->touched_p ()) + add (base_reg, true); + } + } } /* Lazily mark the cluster containing REG as being reachable, recursively -- 2.26.2