From 33fc05f73cff49850868176a6042d189943f71fc Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Wed, 3 Sep 2003 20:23:27 +0000 Subject: plug mem leaks, pr3425 from patrick latifi. ok deraadt@ --- usr.sbin/lpr/lpd/lpd.c | 6 ++++-- usr.sbin/lpr/lpq/lpq.c | 9 ++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'usr.sbin/lpr') diff --git a/usr.sbin/lpr/lpd/lpd.c b/usr.sbin/lpr/lpd/lpd.c index 005ad835a1c..d176c432bbf 100644 --- a/usr.sbin/lpr/lpd/lpd.c +++ b/usr.sbin/lpr/lpd/lpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lpd.c,v 1.39 2003/06/02 23:36:53 millert Exp $ */ +/* $OpenBSD: lpd.c,v 1.40 2003/09/03 20:23:26 tedu Exp $ */ /* $NetBSD: lpd.c,v 1.33 2002/01/21 14:42:29 wiz Exp $ */ /* @@ -41,7 +41,7 @@ static const char copyright[] = #if 0 static const char sccsid[] = "@(#)lpd.c 8.7 (Berkeley) 5/10/95"; #else -static const char rcsid[] = "$OpenBSD: lpd.c,v 1.39 2003/06/02 23:36:53 millert Exp $"; +static const char rcsid[] = "$OpenBSD: lpd.c,v 1.40 2003/09/03 20:23:26 tedu Exp $"; #endif #endif /* not lint */ @@ -653,6 +653,8 @@ ckqueue(char *cap) if (cgetstr(cap, "sd", &spooldir) == -1) spooldir = _PATH_DEFSPOOL; dirp = opendir(spooldir); + if (spooldir != _PATH_DEFSPOOL) + free(spooldir); if (dirp == NULL) return (-1); while ((d = readdir(dirp)) != NULL) { diff --git a/usr.sbin/lpr/lpq/lpq.c b/usr.sbin/lpr/lpq/lpq.c index 735d1df7a4a..98b94c94fba 100644 --- a/usr.sbin/lpr/lpq/lpq.c +++ b/usr.sbin/lpr/lpq/lpq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lpq.c,v 1.14 2003/06/02 23:36:53 millert Exp $ */ +/* $OpenBSD: lpq.c,v 1.15 2003/09/03 20:23:26 tedu Exp $ */ /* $NetBSD: lpq.c,v 1.9 1999/12/07 14:54:47 mrg Exp $ */ /* @@ -41,7 +41,7 @@ static const char copyright[] = #if 0 static const char sccsid[] = "@(#)lpq.c 8.3 (Berkeley) 5/10/95"; #else -static const char rcsid[] = "$OpenBSD: lpq.c,v 1.14 2003/06/02 23:36:53 millert Exp $"; +static const char rcsid[] = "$OpenBSD: lpq.c,v 1.15 2003/09/03 20:23:26 tedu Exp $"; #endif #endif /* not lint */ @@ -171,7 +171,10 @@ ckqueue(char *cap) if (cgetstr(cap, "sd", &spooldir) == -1) spooldir = _PATH_DEFSPOOL; - if ((dirp = opendir(spooldir)) == NULL) + dirp = opendir(spooldir); + if (spooldir != _PATH_DEFSPOOL) + free(spooldir); + if (dirp == NULL) return (-1); while ((d = readdir(dirp)) != NULL) { if (d->d_name[0] != 'c' || d->d_name[1] != 'f') -- cgit v1.2.3