Commit 65985384 authored by Chen Wei's avatar Chen Wei

fix memory leak

parent 79410e2f
...@@ -627,6 +627,8 @@ int main (int argc, char **argv) ...@@ -627,6 +627,8 @@ int main (int argc, char **argv)
} }
#ifdef HAVE_LINUX_NETWORK #ifdef HAVE_LINUX_NETWORK
free(hdr);
free(data);
if (option_bool(OPT_DEBUG)) if (option_bool(OPT_DEBUG))
prctl(PR_SET_DUMPABLE, 1, 0, 0, 0); prctl(PR_SET_DUMPABLE, 1, 0, 0, 0);
#endif #endif
......
...@@ -2354,6 +2354,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma ...@@ -2354,6 +2354,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
np = add_or_lookup_domain(daemon->dh_special_domains, domain); np = add_or_lookup_domain(daemon->dh_special_domains, domain);
} }
free(domain);
// domain unrecognizable // domain unrecognizable
if (np == NULL) if (np == NULL)
continue; continue;
...@@ -2489,6 +2490,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma ...@@ -2489,6 +2490,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
if (domain != NULL) if (domain != NULL)
np = add_or_lookup_domain (daemon->dh_ipsets, domain); np = add_or_lookup_domain (daemon->dh_ipsets, domain);
free(domain);
arg = end; arg = end;
} }
...@@ -2517,12 +2519,18 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma ...@@ -2517,12 +2519,18 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
} }
while (end); while (end);
struct ipsets_names *old_obj;
*sets_pos = NULL; *sets_pos = NULL;
if (np != NULL) if (np != NULL)
{ {
obj = opt_malloc(sizeof(struct ipsets_names)); obj = opt_malloc(sizeof(struct ipsets_names));
obj->sets = sets; obj->sets = sets;
obj->count = sets_count; obj->count = sets_count;
if (np->obj != NULL) {
old_obj = (struct ipsets_names *) np->obj;
free(old_obj->sets);
free(old_obj);
}
np->obj = (void *) obj; np->obj = (void *) obj;
} }
...@@ -4477,7 +4485,7 @@ void read_opts(int argc, char **argv, char *compile_opts) ...@@ -4477,7 +4485,7 @@ void read_opts(int argc, char **argv, char *compile_opts)
{ {
char *buff = opt_malloc(MAXDNAME); char *buff = opt_malloc(MAXDNAME);
int option, conffile_opt = '7', testmode = 0; int option, conffile_opt = '7', testmode = 0;
char *arg, *conffile = CONFFILE; char *arg, *conffile = NULL;
opterr = 0; opterr = 0;
...@@ -4592,7 +4600,15 @@ void read_opts(int argc, char **argv, char *compile_opts) ...@@ -4592,7 +4600,15 @@ void read_opts(int argc, char **argv, char *compile_opts)
} }
if (conffile) if (conffile)
one_file(conffile, conffile_opt); {
one_file(conffile, conffile_opt);
free(conffile);
}
else
{
one_file(CONFFILE, conffile_opt);
}
/* port might not be known when the address is parsed - fill in here */ /* port might not be known when the address is parsed - fill in here */
if (daemon->servers) if (daemon->servers)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment