From 0e353c7b295f20b3cd6ba1126980a20e2c90d073 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Mon, 11 Feb 2013 10:10:17 +0100 Subject: [PATCH] Fixed some more memory leaks. --- lib/config/config_parser.cc | 82 ++++++++++++++++++++----------------- lib/config/config_parser.yy | 8 ++++ 2 files changed, 53 insertions(+), 37 deletions(-) diff --git a/lib/config/config_parser.cc b/lib/config/config_parser.cc index 3f42403b6..b8c015b24 100644 --- a/lib/config/config_parser.cc +++ b/lib/config/config_parser.cc @@ -579,12 +579,12 @@ static const yytype_int8 yyrhs[] = static const yytype_uint16 yyrline[] = { 0, 119, 119, 120, 123, 123, 123, 123, 126, 131, - 137, 142, 143, 150, 149, 179, 182, 189, 188, 200, - 201, 203, 204, 205, 208, 212, 216, 221, 229, 230, - 236, 237, 238, 239, 240, 247, 252, 247, 277, 278, - 281, 285, 291, 292, 295, 302, 303, 307, 306, 318, - 319, 321, 322, 323, 326, 334, 348, 357, 358, 359, - 360, 361, 367, 372, 376, 382, 383 + 137, 143, 144, 152, 151, 181, 184, 191, 190, 202, + 203, 205, 206, 207, 210, 215, 220, 227, 236, 237, + 244, 245, 246, 247, 248, 255, 260, 255, 285, 286, + 289, 293, 299, 300, 303, 310, 311, 315, 314, 326, + 327, 329, 330, 331, 334, 342, 356, 365, 366, 367, + 368, 369, 375, 380, 384, 390, 391 }; #endif @@ -1651,22 +1651,24 @@ yyreduce: #line 138 "config_parser.yy" { context->HandleLibrary((yyvsp[(2) - (2)].text)); + free((yyvsp[(2) - (2)].text)); } break; case 12: /* Line 1806 of yacc.c */ -#line 144 "config_parser.yy" +#line 145 "config_parser.yy" { (yyval.text) = (yyvsp[(1) - (1)].text); + free((yyvsp[(1) - (1)].text)); } break; case 13: /* Line 1806 of yacc.c */ -#line 150 "config_parser.yy" +#line 152 "config_parser.yy" { String name = String((yyvsp[(3) - (3)].text)); free((yyvsp[(3) - (3)].text)); @@ -1686,7 +1688,7 @@ yyreduce: case 14: /* Line 1806 of yacc.c */ -#line 165 "config_parser.yy" +#line 167 "config_parser.yy" { TypeRuleList::Ptr ruleList = *(yyvsp[(6) - (6)].variant); m_Type->GetRuleList()->AddRules(ruleList); @@ -1703,7 +1705,7 @@ yyreduce: case 15: /* Line 1806 of yacc.c */ -#line 179 "config_parser.yy" +#line 181 "config_parser.yy" { (yyval.num) = 0; } @@ -1712,7 +1714,7 @@ yyreduce: case 16: /* Line 1806 of yacc.c */ -#line 183 "config_parser.yy" +#line 185 "config_parser.yy" { (yyval.num) = 1; } @@ -1721,7 +1723,7 @@ yyreduce: case 17: /* Line 1806 of yacc.c */ -#line 189 "config_parser.yy" +#line 191 "config_parser.yy" { m_RuleLists.push(boost::make_shared()); } @@ -1730,7 +1732,7 @@ yyreduce: case 18: /* Line 1806 of yacc.c */ -#line 194 "config_parser.yy" +#line 196 "config_parser.yy" { (yyval.variant) = new Value(m_RuleLists.top()); m_RuleLists.pop(); @@ -1740,27 +1742,31 @@ yyreduce: case 24: /* Line 1806 of yacc.c */ -#line 209 "config_parser.yy" +#line 211 "config_parser.yy" { m_RuleLists.top()->AddRequire((yyvsp[(2) - (2)].text)); + free((yyvsp[(2) - (2)].text)); } break; case 25: /* Line 1806 of yacc.c */ -#line 213 "config_parser.yy" +#line 216 "config_parser.yy" { m_RuleLists.top()->SetValidator((yyvsp[(2) - (2)].text)); + free((yyvsp[(2) - (2)].text)); } break; case 26: /* Line 1806 of yacc.c */ -#line 217 "config_parser.yy" +#line 221 "config_parser.yy" { TypeRule rule((yyvsp[(2) - (3)].type), (yyvsp[(3) - (3)].text), TypeRuleList::Ptr(), yylloc); + free((yyvsp[(3) - (3)].text)); + m_RuleLists.top()->AddRule(rule); } break; @@ -1768,9 +1774,10 @@ yyreduce: case 27: /* Line 1806 of yacc.c */ -#line 222 "config_parser.yy" +#line 228 "config_parser.yy" { TypeRule rule((yyvsp[(2) - (4)].type), (yyvsp[(3) - (4)].text), *(yyvsp[(4) - (4)].variant), yylloc); + free((yyvsp[(3) - (4)].text)); delete (yyvsp[(4) - (4)].variant); m_RuleLists.top()->AddRule(rule); } @@ -1779,16 +1786,17 @@ yyreduce: case 29: /* Line 1806 of yacc.c */ -#line 231 "config_parser.yy" +#line 238 "config_parser.yy" { m_Type->SetParent((yyvsp[(2) - (2)].text)); + free((yyvsp[(2) - (2)].text)); } break; case 34: /* Line 1806 of yacc.c */ -#line 241 "config_parser.yy" +#line 249 "config_parser.yy" { (yyval.type) = (yyvsp[(1) - (1)].type); } @@ -1797,7 +1805,7 @@ yyreduce: case 35: /* Line 1806 of yacc.c */ -#line 247 "config_parser.yy" +#line 255 "config_parser.yy" { m_Abstract = false; m_Local = false; @@ -1807,7 +1815,7 @@ yyreduce: case 36: /* Line 1806 of yacc.c */ -#line 252 "config_parser.yy" +#line 260 "config_parser.yy" { m_Item = boost::make_shared(yylloc); @@ -1824,7 +1832,7 @@ yyreduce: case 37: /* Line 1806 of yacc.c */ -#line 264 "config_parser.yy" +#line 272 "config_parser.yy" { ExpressionList::Ptr exprl = *(yyvsp[(8) - (8)].variant); delete (yyvsp[(8) - (8)].variant); @@ -1841,7 +1849,7 @@ yyreduce: case 40: /* Line 1806 of yacc.c */ -#line 282 "config_parser.yy" +#line 290 "config_parser.yy" { m_Abstract = true; } @@ -1850,7 +1858,7 @@ yyreduce: case 41: /* Line 1806 of yacc.c */ -#line 286 "config_parser.yy" +#line 294 "config_parser.yy" { m_Local = true; } @@ -1859,7 +1867,7 @@ yyreduce: case 44: /* Line 1806 of yacc.c */ -#line 296 "config_parser.yy" +#line 304 "config_parser.yy" { m_Item->AddParent((yyvsp[(1) - (1)].text)); free((yyvsp[(1) - (1)].text)); @@ -1869,7 +1877,7 @@ yyreduce: case 47: /* Line 1806 of yacc.c */ -#line 307 "config_parser.yy" +#line 315 "config_parser.yy" { m_ExpressionLists.push(boost::make_shared()); } @@ -1878,7 +1886,7 @@ yyreduce: case 48: /* Line 1806 of yacc.c */ -#line 312 "config_parser.yy" +#line 320 "config_parser.yy" { (yyval.variant) = new Value(m_ExpressionLists.top()); m_ExpressionLists.pop(); @@ -1888,7 +1896,7 @@ yyreduce: case 54: /* Line 1806 of yacc.c */ -#line 327 "config_parser.yy" +#line 335 "config_parser.yy" { Expression expr((yyvsp[(1) - (3)].text), (yyvsp[(2) - (3)].op), *(yyvsp[(3) - (3)].variant), yylloc); free((yyvsp[(1) - (3)].text)); @@ -1901,7 +1909,7 @@ yyreduce: case 55: /* Line 1806 of yacc.c */ -#line 335 "config_parser.yy" +#line 343 "config_parser.yy" { Expression subexpr((yyvsp[(3) - (6)].text), (yyvsp[(5) - (6)].op), *(yyvsp[(6) - (6)].variant), yylloc); free((yyvsp[(3) - (6)].text)); @@ -1920,7 +1928,7 @@ yyreduce: case 56: /* Line 1806 of yacc.c */ -#line 349 "config_parser.yy" +#line 357 "config_parser.yy" { Expression expr((yyvsp[(1) - (1)].text), OperatorSet, (yyvsp[(1) - (1)].text), yylloc); free((yyvsp[(1) - (1)].text)); @@ -1932,7 +1940,7 @@ yyreduce: case 61: /* Line 1806 of yacc.c */ -#line 362 "config_parser.yy" +#line 370 "config_parser.yy" { (yyval.op) = (yyvsp[(1) - (1)].op); } @@ -1941,7 +1949,7 @@ yyreduce: case 62: /* Line 1806 of yacc.c */ -#line 368 "config_parser.yy" +#line 376 "config_parser.yy" { (yyval.variant) = new Value((yyvsp[(1) - (1)].text)); free((yyvsp[(1) - (1)].text)); @@ -1951,7 +1959,7 @@ yyreduce: case 63: /* Line 1806 of yacc.c */ -#line 373 "config_parser.yy" +#line 381 "config_parser.yy" { (yyval.variant) = new Value((yyvsp[(1) - (1)].num)); } @@ -1960,7 +1968,7 @@ yyreduce: case 64: /* Line 1806 of yacc.c */ -#line 377 "config_parser.yy" +#line 385 "config_parser.yy" { (yyval.variant) = new Value(); } @@ -1969,7 +1977,7 @@ yyreduce: case 66: /* Line 1806 of yacc.c */ -#line 384 "config_parser.yy" +#line 392 "config_parser.yy" { (yyval.variant) = (yyvsp[(1) - (1)].variant); } @@ -1978,7 +1986,7 @@ yyreduce: /* Line 1806 of yacc.c */ -#line 1982 "config_parser.cc" +#line 1990 "config_parser.cc" default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -2216,6 +2224,6 @@ yyreturn: /* Line 2067 of yacc.c */ -#line 388 "config_parser.yy" +#line 396 "config_parser.yy" diff --git a/lib/config/config_parser.yy b/lib/config/config_parser.yy index 9b70735c4..df4809db1 100644 --- a/lib/config/config_parser.yy +++ b/lib/config/config_parser.yy @@ -137,12 +137,14 @@ include: T_INCLUDE T_STRING library: T_LIBRARY T_STRING { context->HandleLibrary($2); + free($2); } identifier: T_IDENTIFIER | T_STRING { $$ = $1; + free($1); } ; @@ -208,19 +210,24 @@ typerules_inner: /* empty */ typerule: T_REQUIRE T_STRING { m_RuleLists.top()->AddRequire($2); + free($2); } | T_VALIDATOR T_STRING { m_RuleLists.top()->SetValidator($2); + free($2); } | T_ATTRIBUTE type T_STRING { TypeRule rule($2, $3, TypeRuleList::Ptr(), yylloc); + free($3); + m_RuleLists.top()->AddRule(rule); } | T_ATTRIBUTE type T_STRING typerulelist { TypeRule rule($2, $3, *$4, yylloc); + free($3); delete $4; m_RuleLists.top()->AddRule(rule); } @@ -230,6 +237,7 @@ type_inherits_specifier: /* empty */ | T_INHERITS T_STRING { m_Type->SetParent($2); + free($2); } ; -- 2.40.0