diff options
author | Martin Josefsson <gandalf@wlug.westbo.se> | 2003-05-02 15:30:11 +0000 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2003-05-02 15:30:11 +0000 |
commit | 841e4aed2349046eb2c0b1375139c06569a93bd0 (patch) | |
tree | 9f7a208076fc164ca3d52e745964c7dbc7afc350 /iptables.c | |
parent | 59cbe17cee0499c8f25a8d9f29513f4c85e9b03c (diff) |
fix memory leak(s) in libiptc. Reverts the previous (wrong) patch. (Martin Josefsson)
Diffstat (limited to 'iptables.c')
-rw-r--r-- | iptables.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -1668,6 +1668,7 @@ int do_command(int argc, char *argv[], char **table, iptc_handle_t *handle) char *protocol = NULL; const char *modprobe = NULL; int proto_used = 0; + int no_handle = 0; memset(&fw, 0, sizeof(fw)); @@ -2148,8 +2149,10 @@ int do_command(int argc, char *argv[], char **table, iptc_handle_t *handle) chain, IPT_FUNCTION_MAXNAMELEN); /* only allocate handle if we weren't called with a handle */ - if (!*handle) + if (!*handle) { *handle = iptc_init(*table); + no_handle = 1; + } if (!*handle) { /* try to insmod the module if iptc_init failed */ @@ -2294,5 +2297,8 @@ int do_command(int argc, char *argv[], char **table, iptc_handle_t *handle) if (verbose > 1) dump_entries(*handle); + if (no_handle) + iptc_free(handle); + return ret; } |