summaryrefslogtreecommitdiffstats
path: root/usr.sbin/cron/lib
diff options
context:
space:
mode:
authordd <dd@FreeBSD.org>2001-07-18 11:48:00 +0000
committerdd <dd@FreeBSD.org>2001-07-18 11:48:00 +0000
commitcb0776eac7517c5f0bed393da83f5a1027b13b20 (patch)
tree557b7503c174788217a66840037a6b81ae57cd5b /usr.sbin/cron/lib
parent80e372cd14a11e2e423d5c2f42c895bd19c8348a (diff)
downloadFreeBSD-src-cb0776eac7517c5f0bed393da83f5a1027b13b20.zip
FreeBSD-src-cb0776eac7517c5f0bed393da83f5a1027b13b20.tar.gz
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>
Diffstat (limited to 'usr.sbin/cron/lib')
-rw-r--r--usr.sbin/cron/lib/entry.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/usr.sbin/cron/lib/entry.c b/usr.sbin/cron/lib/entry.c
index c7562a2..2554827 100644
--- a/usr.sbin/cron/lib/entry.c
+++ b/usr.sbin/cron/lib/entry.c
@@ -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;
}
OpenPOWER on IntegriCloud