[BusyBox-cvs] busybox/networking/udhcp script.c,1.14,1.15

Russ Dill,,, russ at busybox.net
Wed May 19 07:45:49 UTC 2004


Update of /var/cvs/busybox/networking/udhcp
In directory nail:/tmp/cvs-serv27193

Modified Files:
	script.c 
Log Message:
fix memory leak caused by switch to vfork

Index: script.c
===================================================================
RCS file: /var/cvs/busybox/networking/udhcp/script.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- a/script.c	14 Apr 2004 17:51:26 -0000	1.14
+++ b/script.c	19 May 2004 07:45:47 -0000	1.15
@@ -206,21 +206,22 @@
 void run_script(struct dhcpMessage *packet, const char *name)
 {
 	int pid;
-	char **envp;
+	char **envp, **curr;
 
 	if (client_config.script == NULL)
 		return;
 
 	DEBUG(LOG_INFO, "vforking and execle'ing %s", client_config.script);
 
+	envp = fill_envp(packet);
 	/* call script */
 	pid = vfork();
 	if (pid) {
 		waitpid(pid, NULL, 0);
+		for (curr = envp; *curr; curr++) free(*curr);
+		free(envp);
 		return;
 	} else if (pid == 0) {
-		envp = fill_envp(packet);
-
 		/* close fd's? */
 
 		/* exec script */




More information about the busybox-cvs mailing list