Fix tc/m_ipt memory leaks
1)optind according iptables sources have to be set to 0. If it is set to 1, in batch it will mess up things. Also in iptables sources i notice that ->tflags and ->used need to be reset. 2)Since target->t = fw_calloc(1, size); allocated memory in function build_st, it have to be freed at the end, or in batch we will have memory leak. TODO: Probably it must be freed in all "return -1" cases in parse_ipt after build_st. About this i am not sure, up to Stephen. 3)new_name was malloc'ed, but not freed
This commit is contained in:
parent
037d950bce
commit
6e34e7dc0a
15
tc/m_ipt.c
15
tc/m_ipt.c
|
|
@ -277,6 +277,8 @@ get_target_name(const char *name)
|
||||||
if (!handle) {
|
if (!handle) {
|
||||||
fputs(dlerror(), stderr);
|
fputs(dlerror(), stderr);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
free(l_name);
|
||||||
|
free(new_name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -292,12 +294,16 @@ get_target_name(const char *name)
|
||||||
fputs(error, stderr);
|
fputs(error, stderr);
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
dlclose(handle);
|
dlclose(handle);
|
||||||
|
free(l_name);
|
||||||
|
free(new_name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(l_name);
|
||||||
|
free(new_name);
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -512,8 +518,15 @@ static int parse_ipt(struct action_util *a,int *argc_p,
|
||||||
*argc_p = rargc - iargc;
|
*argc_p = rargc - iargc;
|
||||||
*argv_p = argv;
|
*argv_p = argv;
|
||||||
|
|
||||||
optind = 1;
|
optind = 0;
|
||||||
free_opts(opts);
|
free_opts(opts);
|
||||||
|
/* Clear flags if target will be used again */
|
||||||
|
m->tflags=0;
|
||||||
|
m->used=0;
|
||||||
|
/* Free allocated memory */
|
||||||
|
if (m->t)
|
||||||
|
free(m->t);
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue