]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
Fix some memory leaks
authorPatrick McHardy <kaber@trash.net>
Fri, 20 Mar 2009 16:42:55 +0000 (17:42 +0100)
committerPatrick McHardy <kaber@trash.net>
Fri, 20 Mar 2009 16:42:55 +0000 (17:42 +0100)
Free nested chain handles and command structures when done.

Signed-off-by: Patrick McHardy <kaber@trash.net>
src/main.c
src/parser.y

index 00f594f669d0ff7639ea776618498a9764d73cb5..3daa294e11f9989db866c5dd0a0d92cacd07f188 100644 (file)
@@ -183,14 +183,16 @@ int main(int argc, char * const *argv)
 
        {
                struct netlink_ctx ctx;
-               struct cmd *cmd;
+               struct cmd *cmd, *next;
 
-               list_for_each_entry(cmd, &state.cmds, list) {
+               list_for_each_entry_safe(cmd, next, &state.cmds, list) {
                        memset(&ctx, 0, sizeof(ctx));
                        ctx.msgs = &msgs;
                        init_list_head(&ctx.list);
                        if (do_command(&ctx, cmd) < 0)
                                goto out;
+                       list_del(&cmd->list);
+                       cmd_free(cmd);
                }
        }
 out:
index d9da115ad4365811d30c6da19e1084e3e2957493..90f9052e4deb4841bce3cbf0d88b94baeed14751 100644 (file)
@@ -576,6 +576,7 @@ table_line          :       CHAIN           chain_identifier        chain_block_alloc
                                                '{'     chain_block     '}'
                        {
                                handle_merge(&$3->handle, &$2);
+                               handle_free(&$2);
                                close_scope(state);
                                $$ = $3;
                        }