From bb930bac45defb9f7d72815d910f9bb6f70262a2 Mon Sep 17 00:00:00 2001 From: des Date: Wed, 29 Jul 1998 17:50:06 +0000 Subject: [PATCH] Don't try to dereference a pointer to freed memory. PR: bin/7393 --- usr.bin/du/du.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/usr.bin/du/du.c b/usr.bin/du/du.c index 4c81e6257fdb..4c75b70a37e8 100644 --- a/usr.bin/du/du.c +++ b/usr.bin/du/du.c @@ -67,8 +67,7 @@ main(argc, argv) { FTS *fts; FTSENT *p; - FTSENT *savedp; - long blocksize; + long blocksize, savednumber = 0; int ftsoptions; int listall; int depth; @@ -184,7 +183,6 @@ main(argc, argv) err(1, "fts_open"); while ((p = fts_read(fts)) != NULL) { - savedp = p; switch (p->fts_info) { case FTS_D: /* Ignore. */ break; @@ -216,15 +214,14 @@ main(argc, argv) p->fts_parent->fts_number += p->fts_statp->st_blocks; } + savednumber = p->fts_number; } if (errno) err(1, "fts_read"); - if (cflag) { - p = savedp->fts_parent; - (void) printf("%ld\ttotal\n", howmany(p->fts_number, blocksize)); - } + if (cflag) + (void) printf("%ld\ttotal\n", howmany(savednumber, blocksize)); exit(rval); }