Skip to content

Commit 83054a0

Browse files
silvakidrsomla1
authored andcommitted
Bug29866610: memory leaks in parser.
Caller of parser method parse() is the owner of the returned Expression object. But the code did not always free this object if it was not used.
1 parent 690c8e2 commit 83054a0

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

cdk/parser/expr_parser.cc

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ Expr_parser_base::parse_function_call(const cdk::api::Table_ref &func, Scalar_pr
358358
)
359359
unsupported("LEADING, TRAILING or BOTH clause inside function TRIM()");
360360

361-
parse(parse_position ? COMP : FULL, aprc ? aprc->list_el() : NULL);
361+
delete parse(parse_position ? COMP : FULL, aprc ? aprc->list_el() : NULL);
362362

363363
if (consume_token(Token::COMMA))
364364
parse_argslist(aprc);
@@ -404,7 +404,7 @@ Expr_parser_base::parse_special_args(
404404
{
405405
if (!consume_token(Keyword::IN))
406406
parse_error("Expected IN inside POSITION(... IN ...)");
407-
parse(FULL, aprc ? aprc->list_el() : NULL);
407+
delete parse(FULL, aprc ? aprc->list_el() : NULL);
408408
return;
409409
}
410410
}
@@ -1082,12 +1082,12 @@ Expression* Expr_parser_base::parse_atomic(Processor *prc)
10821082
case Token::LPAREN:
10831083
{
10841084
consume_token();
1085-
Expression *res = parse(FULL, prc);
1085+
smart_ptr<Expression> res(parse(FULL, prc));
10861086
consume_token_throw(
10871087
Token::RPAREN,
10881088
"Expected ')' to close parenthesized sub-expression"
10891089
);
1090-
return res;
1090+
return res.release();
10911091
}
10921092

10931093
default: break;
@@ -1179,7 +1179,7 @@ Expression* Expr_parser_base::parse_atomic(Processor *prc)
11791179
if (argsp)
11801180
{
11811181
argsp->list_begin();
1182-
parse(ATOMIC, argsp->list_el());
1182+
delete parse(ATOMIC, argsp->list_el());
11831183
argsp->list_end();
11841184
return stored.release();
11851185
}
@@ -1443,7 +1443,7 @@ Expr_parser_base::left_assoc_binary_op(const Op::Set &ops,
14431443

14441444
// then parse rhs, passing it as 2nd argument
14451445

1446-
parse(rhs, aprc->list_el());
1446+
delete parse(rhs, aprc->list_el());
14471447

14481448
aprc->list_end();
14491449
}
@@ -1493,7 +1493,7 @@ Expression* Expr_parser_base::parse_bit(Processor *prc)
14931493
if (argsp)
14941494
{
14951495
argsp->list_begin();
1496-
parse(ATOMIC, argsp->list_el());
1496+
delete parse(ATOMIC, argsp->list_el());
14971497
argsp->list_end();
14981498
return stored.release();
14991499
}
@@ -1727,7 +1727,7 @@ Expression* Expr_parser_base::parse_ilri(Processor *prc)
17271727
}
17281728
else
17291729
{
1730-
parse(COMP, aprc->list_el());
1730+
delete parse(COMP, aprc->list_el());
17311731
}
17321732

17331733
break;
@@ -1738,7 +1738,7 @@ Expression* Expr_parser_base::parse_ilri(Processor *prc)
17381738
case Op::RLIKE:
17391739
case Op::NOT_RLIKE:
17401740
{
1741-
parse(COMP, aprc->list_el());
1741+
delete parse(COMP, aprc->list_el());
17421742

17431743
if (cur_token_type_is(Keyword::ESCAPE))
17441744
{
@@ -1750,22 +1750,22 @@ Expression* Expr_parser_base::parse_ilri(Processor *prc)
17501750

17511751
case Op::REGEXP:
17521752
case Op::NOT_REGEXP:
1753-
parse(COMP, aprc->list_el());
1753+
delete parse(COMP, aprc->list_el());
17541754
break;
17551755

17561756
case Op::OVERLAPS:
17571757
case Op::NOT_OVERLAPS:
1758-
parse(COMP, aprc->list_el());
1758+
delete parse(COMP, aprc->list_el());
17591759
break;
17601760

17611761
case Op::BETWEEN:
17621762
case Op::NOT_BETWEEN:
1763-
parse(COMP, aprc->list_el());
1763+
delete parse(COMP, aprc->list_el());
17641764
consume_token_throw(
17651765
Keyword::AND,
17661766
"Expected AND in BETWEEN ... expression"
17671767
);
1768-
parse(COMP, aprc->list_el());
1768+
delete parse(COMP, aprc->list_el());
17691769
break;
17701770

17711771
default: assert(false);

0 commit comments

Comments
 (0)