summaryrefslogtreecommitdiffstats
path: root/usr.bin/last/last.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/last/last.c')
-rw-r--r--usr.bin/last/last.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.bin/last/last.c b/usr.bin/last/last.c
index 89dcef8..25a7627 100644
--- a/usr.bin/last/last.c
+++ b/usr.bin/last/last.c
@@ -162,7 +162,7 @@ void
wtmp()
{
struct utmp *bp; /* current structure */
- struct ttytab *tt; /* ttylist entry */
+ struct ttytab *tt, *ttx; /* ttylist entry */
struct stat stb; /* stat of file for size */
long bl, delta; /* time difference */
int bytes, wfd;
@@ -191,9 +191,11 @@ wtmp()
*/
if (bp->ut_line[0] == '~' && !bp->ut_line[1]) {
/* everybody just logged out */
- for (tt = ttylist.lh_first; tt; tt = tt->list.le_next) {
+ for (tt = ttylist.lh_first; tt;) {
LIST_REMOVE(tt, list);
- free(tt);
+ ttx = tt;
+ tt = tt->list.le_next;
+ free(ttx);
}
currentout = -bp->ut_time;
crmsg = strncmp(bp->ut_name, "shutdown",
OpenPOWER on IntegriCloud