diff options
author | Martin Liska <mliska@suse.cz> | 2016-05-19 17:06:17 +0200 |
---|---|---|
committer | Martin Liska <marxin@gcc.gnu.org> | 2016-05-19 15:06:17 +0000 |
commit | 7f153d8202c35578ca22746d2c3297f4a83272fb (patch) | |
tree | 75c97bac01fb9766b882d72ef3defb04a2e4f7b7 /gcc/ipa-pure-const.c | |
parent | 6e078af89e237f8c4e139703a1bb83bd7671858c (diff) | |
download | gcc-7f153d8202c35578ca22746d2c3297f4a83272fb.zip gcc-7f153d8202c35578ca22746d2c3297f4a83272fb.tar.gz gcc-7f153d8202c35578ca22746d2c3297f4a83272fb.tar.bz2 |
Fix memory leak in ipa-pure-const
* ipa-pure-const.c (set_function_state): Remove an existing
funct_state.
(remove_node_data): Do not free it as it's released
in set_function_state.
From-SVN: r236469
Diffstat (limited to 'gcc/ipa-pure-const.c')
-rw-r--r-- | gcc/ipa-pure-const.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c index ba76275..a9570e4 100644 --- a/gcc/ipa-pure-const.c +++ b/gcc/ipa-pure-const.c @@ -258,6 +258,13 @@ set_function_state (struct cgraph_node *node, funct_state s) if (!funct_state_vec.exists () || funct_state_vec.length () <= (unsigned int)node->uid) funct_state_vec.safe_grow_cleared (node->uid + 1); + + /* If funct_state_vec already contains a funct_state, we have to release + it before it's going to be ovewritten. */ + if (funct_state_vec[node->uid] != NULL + && funct_state_vec[node->uid] != &varying_state) + free (funct_state_vec[node->uid]); + funct_state_vec[node->uid] = s; } @@ -956,12 +963,7 @@ static void remove_node_data (struct cgraph_node *node, void *data ATTRIBUTE_UNUSED) { if (has_function_state (node)) - { - funct_state l = get_function_state (node); - if (l != &varying_state) - free (l); - set_function_state (node, NULL); - } + set_function_state (node, NULL); } |