diff options
author | Russ Dill <Russ.Dill@asu.edu> | 2004-05-19 07:45:47 +0000 |
---|---|---|
committer | Russ Dill <Russ.Dill@asu.edu> | 2004-05-19 07:45:47 +0000 |
commit | 57f49d318552b093def4ecd2287d02b30f6d238b (patch) | |
tree | 2af6d3f9b12d914acbc76164b495105f2f54112c | |
parent | 21d7d61de164b25bc6a70e49b12567e80caed953 (diff) | |
download | busybox-w32-57f49d318552b093def4ecd2287d02b30f6d238b.tar.gz busybox-w32-57f49d318552b093def4ecd2287d02b30f6d238b.tar.bz2 busybox-w32-57f49d318552b093def4ecd2287d02b30f6d238b.zip |
fix memory leak caused by switch to vfork
-rw-r--r-- | networking/udhcp/script.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/networking/udhcp/script.c b/networking/udhcp/script.c index e0a8dad53..820fbb064 100644 --- a/networking/udhcp/script.c +++ b/networking/udhcp/script.c | |||
@@ -206,21 +206,22 @@ static char **fill_envp(struct dhcpMessage *packet) | |||
206 | void run_script(struct dhcpMessage *packet, const char *name) | 206 | void run_script(struct dhcpMessage *packet, const char *name) |
207 | { | 207 | { |
208 | int pid; | 208 | int pid; |
209 | char **envp; | 209 | char **envp, **curr; |
210 | 210 | ||
211 | if (client_config.script == NULL) | 211 | if (client_config.script == NULL) |
212 | return; | 212 | return; |
213 | 213 | ||
214 | DEBUG(LOG_INFO, "vforking and execle'ing %s", client_config.script); | 214 | DEBUG(LOG_INFO, "vforking and execle'ing %s", client_config.script); |
215 | 215 | ||
216 | envp = fill_envp(packet); | ||
216 | /* call script */ | 217 | /* call script */ |
217 | pid = vfork(); | 218 | pid = vfork(); |
218 | if (pid) { | 219 | if (pid) { |
219 | waitpid(pid, NULL, 0); | 220 | waitpid(pid, NULL, 0); |
221 | for (curr = envp; *curr; curr++) free(*curr); | ||
222 | free(envp); | ||
220 | return; | 223 | return; |
221 | } else if (pid == 0) { | 224 | } else if (pid == 0) { |
222 | envp = fill_envp(packet); | ||
223 | |||
224 | /* close fd's? */ | 225 | /* close fd's? */ |
225 | 226 | ||
226 | /* exec script */ | 227 | /* exec script */ |