]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
src: missing destroy function in statement definitions
authorPablo Neira Ayuso <pablo@netfilter.org>
Fri, 5 Apr 2019 13:35:36 +0000 (15:35 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 5 Apr 2019 13:48:36 +0000 (15:48 +0200)
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/ct.c
src/exthdr.c
src/meta.c
src/payload.c
src/statement.c
src/xt.c

index e872857bded0f94c6c1934884ac808f575d1b17f..2256ce3222912de5fb6e97efd0d1fed9de6924df 100644 (file)
--- a/src/ct.c
+++ b/src/ct.c
@@ -440,11 +440,17 @@ static void ct_stmt_print(const struct stmt *stmt, struct output_ctx *octx)
        expr_print(stmt->ct.expr, octx);
 }
 
+static void ct_stmt_destroy(struct stmt *stmt)
+{
+       expr_free(stmt->ct.expr);
+}
+
 static const struct stmt_ops ct_stmt_ops = {
        .type           = STMT_CT,
        .name           = "ct",
        .print          = ct_stmt_print,
        .json           = ct_stmt_json,
+       .destroy        = ct_stmt_destroy,
 };
 
 struct stmt *ct_stmt_alloc(const struct location *loc, enum nft_ct_keys key,
@@ -484,10 +490,16 @@ static void flow_offload_stmt_print(const struct stmt *stmt,
        nft_print(octx, "flow add @%s", stmt->flow.table_name);
 }
 
+static void flow_offload_stmt_destroy(struct stmt *stmt)
+{
+       xfree(stmt->flow.table_name);
+}
+
 static const struct stmt_ops flow_offload_stmt_ops = {
        .type           = STMT_FLOW_OFFLOAD,
        .name           = "flow_offload",
        .print          = flow_offload_stmt_print,
+       .destroy        = flow_offload_stmt_destroy,
 };
 
 struct stmt *flow_offload_stmt_alloc(const struct location *loc,
index 91d2430ab123981f73ce227f2234dfd4143d73bc..0cd0319800730ba7aecb540163cc40bf7874c3f0 100644 (file)
@@ -104,11 +104,18 @@ static void exthdr_stmt_print(const struct stmt *stmt, struct output_ctx *octx)
        expr_print(stmt->exthdr.val, octx);
 }
 
+static void exthdr_stmt_destroy(struct stmt *stmt)
+{
+       expr_free(stmt->exthdr.expr);
+       expr_free(stmt->exthdr.val);
+}
+
 static const struct stmt_ops exthdr_stmt_ops = {
        .type           = STMT_EXTHDR,
        .name           = "exthdr",
        .print          = exthdr_stmt_print,
        .json           = exthdr_stmt_json,
+       .destroy        = exthdr_stmt_destroy,
 };
 
 struct stmt *exthdr_stmt_alloc(const struct location *loc,
index 7e44a2a3545c803a31107eba2d618756738f06f9..583e790ff47d035b2ea08b141fcf88d109b52a4a 100644 (file)
@@ -607,11 +607,17 @@ static void meta_stmt_print(const struct stmt *stmt, struct output_ctx *octx)
        expr_print(stmt->meta.expr, octx);
 }
 
+static void meta_stmt_destroy(struct stmt *stmt)
+{
+       expr_free(stmt->meta.expr);
+}
+
 static const struct stmt_ops meta_stmt_ops = {
        .type           = STMT_META,
        .name           = "meta",
        .print          = meta_stmt_print,
        .json           = meta_stmt_json,
+       .destroy        = meta_stmt_destroy,
 };
 
 struct stmt *meta_stmt_alloc(const struct location *loc, enum nft_meta_keys key,
index abe9315da389645b0c378114a9de92554c6dc1be..338a4b762cf8fba3c6fd3e588107821c1b7f1df7 100644 (file)
@@ -189,11 +189,18 @@ static void payload_stmt_print(const struct stmt *stmt, struct output_ctx *octx)
        expr_print(stmt->payload.val, octx);
 }
 
+static void payload_stmt_destroy(struct stmt *stmt)
+{
+       expr_free(stmt->payload.expr);
+       expr_free(stmt->payload.val);
+}
+
 static const struct stmt_ops payload_stmt_ops = {
        .type           = STMT_PAYLOAD,
        .name           = "payload",
        .print          = payload_stmt_print,
        .json           = payload_stmt_json,
+       .destroy        = payload_stmt_destroy,
 };
 
 struct stmt *payload_stmt_alloc(const struct location *loc,
index b9324fd7b2ed42a77a1c073f14f6a75fc3d1702a..9b45b3c5bac3b782828ed7a4cbe4117647b61055 100644 (file)
@@ -136,6 +136,7 @@ static void meter_stmt_destroy(struct stmt *stmt)
        expr_free(stmt->meter.key);
        expr_free(stmt->meter.set);
        stmt_free(stmt->meter.stmt);
+       xfree(stmt->meter.name);
 }
 
 static const struct stmt_ops meter_stmt_ops = {
@@ -234,11 +235,17 @@ static void objref_stmt_print(const struct stmt *stmt, struct output_ctx *octx)
        expr_print(stmt->objref.expr, octx);
 }
 
+static void objref_stmt_destroy(struct stmt *stmt)
+{
+       expr_free(stmt->objref.expr);
+}
+
 static const struct stmt_ops objref_stmt_ops = {
        .type           = STMT_OBJREF,
        .name           = "objref",
        .print          = objref_stmt_print,
        .json           = objref_stmt_json,
+       .destroy        = objref_stmt_destroy,
 };
 
 struct stmt *objref_stmt_alloc(const struct location *loc)
@@ -443,11 +450,17 @@ static void queue_stmt_print(const struct stmt *stmt, struct output_ctx *octx)
 
 }
 
+static void queue_stmt_destroy(struct stmt *stmt)
+{
+       expr_free(stmt->queue.queue);
+}
+
 static const struct stmt_ops queue_stmt_ops = {
        .type           = STMT_QUEUE,
        .name           = "queue",
        .print          = queue_stmt_print,
        .json           = queue_stmt_json,
+       .destroy        = queue_stmt_destroy,
 };
 
 struct stmt *queue_stmt_alloc(const struct location *loc)
@@ -519,11 +532,17 @@ static void reject_stmt_print(const struct stmt *stmt, struct output_ctx *octx)
        }
 }
 
+static void reject_stmt_destroy(struct stmt *stmt)
+{
+       expr_free(stmt->reject.expr);
+}
+
 static const struct stmt_ops reject_stmt_ops = {
        .type           = STMT_REJECT,
        .name           = "reject",
        .print          = reject_stmt_print,
        .json           = reject_stmt_json,
+       .destroy        = reject_stmt_destroy,
 };
 
 struct stmt *reject_stmt_alloc(const struct location *loc)
@@ -652,6 +671,7 @@ static void set_stmt_destroy(struct stmt *stmt)
 {
        expr_free(stmt->set.key);
        expr_free(stmt->set.set);
+       stmt_free(stmt->set.stmt);
 }
 
 static const struct stmt_ops set_stmt_ops = {
@@ -691,6 +711,7 @@ static void map_stmt_destroy(struct stmt *stmt)
        expr_free(stmt->map.key);
        expr_free(stmt->map.data);
        expr_free(stmt->map.set);
+       stmt_free(stmt->map.stmt);
 }
 
 static const struct stmt_ops map_stmt_ops = {
index c80e1fc0b2b0d8e7288e3c7e19b5b2951d5a13a6..906b2fde10e1328b8e8f4f258eca6f7a07e98ac3 100644 (file)
--- a/src/xt.c
+++ b/src/xt.c
@@ -102,6 +102,7 @@ void xt_stmt_release(const struct stmt *stmt)
        }
 #endif
        xfree(stmt->xt.entry);
+       xfree(stmt->xt.name);
 }
 
 #ifdef HAVE_LIBXTABLES