fix memory leaks
This commit is contained in:
parent
b7828e698e
commit
bf255c65ac
|
@ -478,8 +478,13 @@ select_no_paren:
|
|||
select_clause opt_order opt_limit {
|
||||
$$ = $1;
|
||||
$$->order = $2;
|
||||
|
||||
// Limit could have been set by TOP.
|
||||
if ($3 != NULL) {
|
||||
delete $$->limit;
|
||||
$$->limit = $3;
|
||||
}
|
||||
}
|
||||
| select_clause set_operator select_clause opt_order opt_limit {
|
||||
// TODO: allow multiple unions (through linked list)
|
||||
// TODO: capture type of set_operator
|
||||
|
@ -487,14 +492,24 @@ select_no_paren:
|
|||
$$ = $1;
|
||||
$$->unionSelect = $3;
|
||||
$$->order = $4;
|
||||
|
||||
// Limit could have been set by TOP.
|
||||
if ($5 != NULL) {
|
||||
delete $$->limit;
|
||||
$$->limit = $5;
|
||||
}
|
||||
}
|
||||
| select_clause set_operator select_with_paren opt_order opt_limit {
|
||||
$$ = $1;
|
||||
$$->unionSelect = $3;
|
||||
$$->order = $4;
|
||||
|
||||
// Limit could have been set by TOP.
|
||||
if ($5 != NULL) {
|
||||
delete $$->limit;
|
||||
$$->limit = $5;
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
set_operator:
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "Expr.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "SelectStatement.h"
|
||||
|
||||
namespace hsql {
|
||||
|
||||
|
@ -9,6 +10,8 @@ namespace hsql {
|
|||
type(type),
|
||||
expr(NULL),
|
||||
expr2(NULL),
|
||||
exprList(NULL),
|
||||
select(NULL),
|
||||
name(NULL),
|
||||
table(NULL),
|
||||
alias(NULL) {};
|
||||
|
@ -16,9 +19,17 @@ namespace hsql {
|
|||
Expr::~Expr() {
|
||||
delete expr;
|
||||
delete expr2;
|
||||
delete select;
|
||||
free(name);
|
||||
free(table);
|
||||
free(alias);
|
||||
|
||||
if (exprList != NULL) {
|
||||
for (Expr* e : *exprList) {
|
||||
delete e;
|
||||
}
|
||||
delete exprList;
|
||||
}
|
||||
}
|
||||
|
||||
Expr* Expr::makeOpUnary(OperatorType op, Expr* expr) {
|
||||
|
|
|
@ -193,7 +193,6 @@ namespace hsql {
|
|||
delete whereClause;
|
||||
delete groupBy;
|
||||
delete unionSelect;
|
||||
delete order;
|
||||
delete limit;
|
||||
|
||||
// Delete each element in the select list.
|
||||
|
@ -203,6 +202,13 @@ namespace hsql {
|
|||
}
|
||||
delete selectList;
|
||||
}
|
||||
|
||||
if (order != NULL) {
|
||||
for (OrderDescription* desc : *order) {
|
||||
delete desc;
|
||||
}
|
||||
delete order;
|
||||
}
|
||||
}
|
||||
|
||||
// UpdateStatement
|
||||
|
|
|
@ -38,6 +38,7 @@ TEST(TPCHQueryTests) {
|
|||
} else {
|
||||
mt::printOk(file_path.c_str());
|
||||
}
|
||||
delete result;
|
||||
}
|
||||
ASSERT_EQ(testsFailed, 0);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue