free_entry(): Don't free e->envp if it's already NULL; likewise for
e->cmd. free_entry() now does the right thing with partially-initialized structures. load_entry(): Don't call env_free() on e->envp throughout the routine before jumping to eof; the free_entry() call at that label will take care of it. The previous behavior resulted in e->envp being free'd twice (well, the second time would usually result in a crash, but that's besides the point); once in load_entry(), and once in free_entry() after the former called the latter. Also note that the check added to free_entry() (above) doesn't help, since e->envp wasn't reset to NULL after env_free(). Submitted by: Mark Peek <mark@whistle.com>
This commit is contained in:
parent
4472b97ffa
commit
3a7ee409fa
@ -73,8 +73,10 @@ free_entry(e)
|
||||
if (e->class != NULL)
|
||||
free(e->class);
|
||||
#endif
|
||||
free(e->cmd);
|
||||
env_free(e->envp);
|
||||
if (e->cmd != NULL)
|
||||
free(e->cmd);
|
||||
if (e->envp != NULL)
|
||||
env_free(e->envp);
|
||||
free(e);
|
||||
}
|
||||
|
||||
@ -399,7 +401,6 @@ load_entry(file, error_func, pw, envp)
|
||||
/* a file without a \n before the EOF is rude, so we'll complain...
|
||||
*/
|
||||
if (ch == EOF) {
|
||||
env_free(e->envp);
|
||||
ecode = e_cmd;
|
||||
goto eof;
|
||||
}
|
||||
@ -409,7 +410,6 @@ load_entry(file, error_func, pw, envp)
|
||||
e->cmd = strdup(cmd);
|
||||
if (e->cmd == NULL) {
|
||||
warn("strdup(\"%d\")", cmd);
|
||||
env_free(e->envp);
|
||||
ecode = e_mem;
|
||||
goto eof;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user