fix memory leak caused by switch to vfork
This commit is contained in:
parent
21d7d61de1
commit
57f49d3185
@ -206,21 +206,22 @@ static char **fill_envp(struct dhcpMessage *packet)
|
|||||||
void run_script(struct dhcpMessage *packet, const char *name)
|
void run_script(struct dhcpMessage *packet, const char *name)
|
||||||
{
|
{
|
||||||
int pid;
|
int pid;
|
||||||
char **envp;
|
char **envp, **curr;
|
||||||
|
|
||||||
if (client_config.script == NULL)
|
if (client_config.script == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DEBUG(LOG_INFO, "vforking and execle'ing %s", client_config.script);
|
DEBUG(LOG_INFO, "vforking and execle'ing %s", client_config.script);
|
||||||
|
|
||||||
|
envp = fill_envp(packet);
|
||||||
/* call script */
|
/* call script */
|
||||||
pid = vfork();
|
pid = vfork();
|
||||||
if (pid) {
|
if (pid) {
|
||||||
waitpid(pid, NULL, 0);
|
waitpid(pid, NULL, 0);
|
||||||
|
for (curr = envp; *curr; curr++) free(*curr);
|
||||||
|
free(envp);
|
||||||
return;
|
return;
|
||||||
} else if (pid == 0) {
|
} else if (pid == 0) {
|
||||||
envp = fill_envp(packet);
|
|
||||||
|
|
||||||
/* close fd's? */
|
/* close fd's? */
|
||||||
|
|
||||||
/* exec script */
|
/* exec script */
|
||||||
|
Loading…
Reference in New Issue
Block a user