summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2005-01-30 20:45:59 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2005-01-30 20:45:59 +0000
commit199a11f81566b4be5d0949f48fb55259a636e470 (patch)
treea0305b6928862c12a6442cd8cbde60037ee4af56 /usr.sbin
parent8898e33c57016bc4af8542c9ceddf4fd357e91ee (diff)
Proper cleanup on malloc failure; Andrey Matveev
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/cron/atrun.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/usr.sbin/cron/atrun.c b/usr.sbin/cron/atrun.c
index e5b75144742..34c4b54f5bb 100644
--- a/usr.sbin/cron/atrun.c
+++ b/usr.sbin/cron/atrun.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: atrun.c,v 1.13 2004/06/17 22:11:55 millert Exp $ */
+/* $OpenBSD: atrun.c,v 1.14 2005/01/30 20:45:58 millert Exp $ */
/*
* Copyright (c) 2002-2003 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -21,7 +21,7 @@
*/
#if !defined(lint) && !defined(LINT)
-static const char rcsid[] = "$OpenBSD: atrun.c,v 1.13 2004/06/17 22:11:55 millert Exp $";
+static const char rcsid[] = "$OpenBSD: atrun.c,v 1.14 2005/01/30 20:45:58 millert Exp $";
#endif
#include "cron.h"
@@ -87,7 +87,7 @@ scan_atjobs(at_db *old_db, struct timeval *tv)
new_db.head = new_db.tail = NULL;
pending = 0;
- while ((file = readdir(atdir))) {
+ while ((file = readdir(atdir)) != NULL) {
if (stat(file->d_name, &statbuf) != 0 ||
!S_ISREG(statbuf.st_mode))
continue;
@@ -113,6 +113,9 @@ scan_atjobs(at_db *old_db, struct timeval *tv)
job = job->next;
free(tjob);
}
+ closedir(atdir);
+ fchdir(cwd);
+ close(cwd);
return (0);
}
job->uid = statbuf.st_uid;