From df3c2945360a0c07579929f20b080ec5f903a0ad Mon Sep 17 00:00:00 2001 From: Bin Cheng Date: Fri, 10 Nov 2017 12:46:33 +0000 Subject: [PATCH] tree-predcom.c (determine_roots_comp): Avoid memory leak by freeing reference of trivial component. * tree-predcom.c (determine_roots_comp): Avoid memory leak by freeing reference of trivial component. From-SVN: r254625 --- gcc/ChangeLog | 5 +++++ gcc/tree-predcom.c | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b82ce62fdff..1ed540a29e3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2017-11-10 Bin Cheng + + * tree-predcom.c (determine_roots_comp): Avoid memory leak by freeing + reference of trivial component. + 2017-11-10 Jakub Jelinek PR bootstrap/82916 diff --git a/gcc/tree-predcom.c b/gcc/tree-predcom.c index fdb32f10529..d078b96cdf0 100644 --- a/gcc/tree-predcom.c +++ b/gcc/tree-predcom.c @@ -1331,7 +1331,14 @@ determine_roots_comp (struct loop *loop, /* Trivial component. */ if (comp->refs.length () <= 1) - return; + { + if (comp->refs.length () == 1) + { + free (comp->refs[0]); + comp->refs.truncate (0); + } + return; + } comp->refs.qsort (order_drefs); FOR_EACH_VEC_ELT (comp->refs, i, a) -- 2.30.2