[iptables PATCH 05/10] xtables: Add a few missing exit calls

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

 



Mostly to reduce noise from valgrind output, add missing calls to
destroy iterators in nft.c and add cleanup for the populated nft_handle
in xtables_eb_save_main().

Signed-off-by: Phil Sutter <phil@xxxxxx>
---
 iptables/nft.c          | 8 ++++++--
 iptables/xtables-save.c | 1 +
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/iptables/nft.c b/iptables/nft.c
index dd8469a920dcc..b2165069c6d89 100644
--- a/iptables/nft.c
+++ b/iptables/nft.c
@@ -1830,12 +1830,15 @@ bool nft_table_find(struct nft_handle *h, const char *tablename)
 		const char *this_tablename =
 			nftnl_table_get(t, NFTNL_TABLE_NAME);
 
-		if (strcmp(tablename, this_tablename) == 0)
-			return true;
+		if (strcmp(tablename, this_tablename) == 0) {
+			ret = true;
+			break;
+		}
 
 		t = nftnl_table_list_iter_next(iter);
 	}
 
+	nftnl_table_list_iter_destroy(iter);
 	nftnl_table_list_free(list);
 
 err:
@@ -1868,6 +1871,7 @@ int nft_for_each_table(struct nft_handle *h,
 		t = nftnl_table_list_iter_next(iter);
 	}
 
+	nftnl_table_list_iter_destroy(iter);
 	nftnl_table_list_free(list);
 	return 0;
 }
diff --git a/iptables/xtables-save.c b/iptables/xtables-save.c
index fc51fcfeb5815..182ae13c276f4 100644
--- a/iptables/xtables-save.c
+++ b/iptables/xtables-save.c
@@ -285,6 +285,7 @@ int xtables_eb_save_main(int argc_, char *argv_[])
 	}
 
 	nft_for_each_table(&h, __ebt_save, !!ctr);
+	nft_fini(&h);
 	return 0;
 }
 
-- 
2.18.0




[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux