[PATCH nft] src: memleak in expressions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Fix memleak in set element and hash expressions destroy path.

Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx>
---
 src/expression.c | 1 +
 src/hash.c       | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/src/expression.c b/src/expression.c
index 0edc1d22ffce..eece12e4fd2d 100644
--- a/src/expression.c
+++ b/src/expression.c
@@ -1097,6 +1097,7 @@ static void set_elem_expr_destroy(struct expr *expr)
 {
 	xfree(expr->comment);
 	expr_free(expr->key);
+	stmt_free(expr->stmt);
 }
 
 static void set_elem_expr_clone(struct expr *new, const struct expr *expr)
diff --git a/src/hash.c b/src/hash.c
index 208f4b6b6779..08e09099024e 100644
--- a/src/hash.c
+++ b/src/hash.c
@@ -56,6 +56,11 @@ static void hash_expr_clone(struct expr *new, const struct expr *expr)
 	new->hash.type = expr->hash.type;
 }
 
+static void hash_expr_destroy(struct expr *expr)
+{
+	expr_free(expr->hash.expr);
+}
+
 const struct expr_ops hash_expr_ops = {
 	.type		= EXPR_HASH,
 	.name		= "hash",
@@ -63,6 +68,7 @@ const struct expr_ops hash_expr_ops = {
 	.json		= hash_expr_json,
 	.cmp		= hash_expr_cmp,
 	.clone		= hash_expr_clone,
+	.destroy	= hash_expr_destroy,
 };
 
 struct expr *hash_expr_alloc(const struct location *loc,
-- 
2.11.0




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux