From 70471fcd509b462e2df865c942239026ab53833d Mon Sep 17 00:00:00 2001
From: dd
Date: Wed, 13 Jun 2001 05:49:37 +0000
Subject: Plug two memory leaks: call login_close() after login_getclass(), and
use free_entry() instead of free() to free a struct _entry.
PR: 28108
Submitted by: Mark Peek
---
usr.sbin/cron/lib/entry.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
(limited to 'usr.sbin/cron')
diff --git a/usr.sbin/cron/lib/entry.c b/usr.sbin/cron/lib/entry.c
index ef05c14..c7562a2 100644
--- a/usr.sbin/cron/lib/entry.c
+++ b/usr.sbin/cron/lib/entry.c
@@ -262,6 +262,9 @@ load_entry(file, error_func, pw, envp)
char *username = cmd; /* temp buffer */
char *s, *group;
struct group *grp;
+#ifdef LOGIN_CAP
+ login_cap_t *lc;
+#endif
Debug(DPARS, ("load_entry()...about to parse username\n"))
ch = get_string(username, MAX_COMMAND, file, " \t");
@@ -287,10 +290,11 @@ load_entry(file, error_func, pw, envp)
ecode = e_mem;
goto eof;
}
- if (login_getclass(e->class) == NULL) {
+ if ((lc = login_getclass(e->class)) == NULL) {
ecode = e_class;
goto eof;
}
+ login_close(lc);
#endif
grp = NULL;
if ((s = strrchr(username, ':')) != NULL) {
@@ -416,7 +420,7 @@ load_entry(file, error_func, pw, envp)
return e;
eof:
- free(e);
+ free_entry(e);
if (ecode != e_none && error_func)
(*error_func)(ecodes[(int)ecode]);
while (ch != EOF && ch != '\n')
--
cgit v1.1