summaryrefslogtreecommitdiffstats
path: root/ip6tables.c
diff options
context:
space:
mode:
authorgandalf <gandalf>2004-05-18 18:09:43 +0000
committergandalf <gandalf>2004-05-18 18:09:43 +0000
commite3053abc92b890e12c5cdb9445e58a234f517e38 (patch)
tree0307b6413a22cf19fb4f6fed029a955a45d268ed /ip6tables.c
parentca1e7686309dfcbfaa1545eed83ec3fe3abed9a6 (diff)
Get rid of some memoryleaks.
Will make ip(6)tables-restore sessions use less memory.
Diffstat (limited to 'ip6tables.c')
-rw-r--r--ip6tables.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/ip6tables.c b/ip6tables.c
index 9e9a529..b2816ba 100644
--- a/ip6tables.c
+++ b/ip6tables.c
@@ -1433,6 +1433,8 @@ delete_entry(const ip6t_chainlabel chain,
ret &= ip6tc_delete_entry(chain, fw, mask, handle);
}
}
+ free(mask);
+
return ret;
}
@@ -1654,6 +1656,8 @@ void clear_rule_matches(struct ip6tables_rule_match **matches)
for (matchp = *matches; matchp;) {
tmp = matchp->next;
+ if (matchp->match->m)
+ free(matchp->match->m);
free(matchp);
matchp = tmp;
}
@@ -1688,9 +1692,6 @@ int do_command6(int argc, char *argv[], char **table, ip6tc_handle_t *handle)
memset(&fw, 0, sizeof(fw));
- opts = original_opts;
- global_option_offset = 0;
-
/* re-set optind to 0 in case do_command gets called
* a second time */
optind = 0;
@@ -2196,6 +2197,9 @@ int do_command6(int argc, char *argv[], char **table, ip6tc_handle_t *handle)
printf("Warning: using chain %s, not extension\n",
jumpto);
+ if (target->t)
+ free(target->t);
+
target = NULL;
}
@@ -2225,6 +2229,7 @@ int do_command6(int argc, char *argv[], char **table, ip6tc_handle_t *handle)
find_target(jumpto, LOAD_MUST_SUCCEED);
} else {
e = generate_entry(&fw, matches, target->t);
+ free(target->t);
}
}
@@ -2302,5 +2307,22 @@ int do_command6(int argc, char *argv[], char **table, ip6tc_handle_t *handle)
clear_rule_matches(&matches);
+ if (e != NULL) {
+ free(e);
+ e = NULL;
+ }
+
+ for (c = 0; c < nsaddrs; c++)
+ free(&saddrs[c]);
+
+ for (c = 0; c < ndaddrs; c++)
+ free(&daddrs[c]);
+
+ if (opts != original_opts) {
+ free(opts);
+ opts = original_opts;
+ global_option_offset = 0;
+ }
+
return ret;
}