diff options
author | Jeff Johnston <jjohnstn@redhat.com> | 2010-01-12 02:24:47 +0300 |
---|---|---|
committer | Jeff Johnston <jjohnstn@redhat.com> | 2010-01-12 02:24:47 +0300 |
commit | eeda30d7d5688c707d0c09d68ab342b285361408 (patch) | |
tree | bc2df4ba11a01d7b8280ecac392d1f06ae8cab7f /newlib/libc | |
parent | d8a439359a582d29a6ee7b9c0d2309f46544e777 (diff) |
2010-01-11 Sebastian Huber <sebastian.huber@embedded-brains.de>
* libc/posix/telldir.c (_cleanupdir): Fixed usage of freed memory.
Diffstat (limited to 'newlib/libc')
-rw-r--r-- | newlib/libc/posix/telldir.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/newlib/libc/posix/telldir.c b/newlib/libc/posix/telldir.c index ad654b148..51784674a 100644 --- a/newlib/libc/posix/telldir.c +++ b/newlib/libc/posix/telldir.c @@ -169,26 +169,26 @@ _DEFUN(_cleanupdir, (dirp), __lock_acquire(dd_hash_lock); #endif for (i = 0; i < NDIRHASH; ++i) { + struct ddloc head; register struct ddloc *lp; register struct ddloc *prevlp; + lp = dd_hash[i]; - while (lp != NULL && lp->loc_dirp == dirp) { - dd_hash[i] = lp->loc_next; - prevlp = lp; - free((caddr_t)lp); - lp = prevlp->loc_next; - } - prevlp = lp; + head.loc_next = lp; + prevlp = &head; while (lp != NULL) { - lp = lp->loc_next; - if (lp != NULL && lp->loc_dirp == dirp) { - prevlp->loc_next = lp->loc_next; + struct ddloc *nextlp; + + nextlp = lp->loc_next; + if (lp->loc_dirp == dirp) { + prevlp->loc_next = nextlp; free((caddr_t)lp); - lp = prevlp; } else prevlp = lp; + lp = nextlp; } + dd_hash[i] = head.loc_next; } #ifdef HAVE_DD_LOCK __lock_release(dd_hash_lock); |