2010-01-11 Sebastian Huber <sebastian.huber@embedded-brains.de>

* libc/posix/telldir.c (_cleanupdir): Fixed usage of freed memory.
This commit is contained in:
Jeff Johnston 2010-01-11 23:24:47 +00:00
parent d8a439359a
commit eeda30d7d5
2 changed files with 15 additions and 11 deletions

View File

@ -1,3 +1,7 @@
2010-01-11 Sebastian Huber <sebastian.huber@embedded-brains.de>
* libc/posix/telldir.c (_cleanupdir): Fixed usage of freed memory.
2010-01-11 Yaakov Selkowitz <yselkowitz@users.sourceforge.net> 2010-01-11 Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
* libc/include/math.h (log2, log2f): Disable macro versions for C++, * libc/include/math.h (log2, log2f): Disable macro versions for C++,

View File

@ -169,26 +169,26 @@ _DEFUN(_cleanupdir, (dirp),
__lock_acquire(dd_hash_lock); __lock_acquire(dd_hash_lock);
#endif #endif
for (i = 0; i < NDIRHASH; ++i) { for (i = 0; i < NDIRHASH; ++i) {
struct ddloc head;
register struct ddloc *lp; register struct ddloc *lp;
register struct ddloc *prevlp; register struct ddloc *prevlp;
lp = dd_hash[i]; lp = dd_hash[i];
while (lp != NULL && lp->loc_dirp == dirp) { head.loc_next = lp;
dd_hash[i] = lp->loc_next; prevlp = &head;
prevlp = lp;
free((caddr_t)lp);
lp = prevlp->loc_next;
}
prevlp = lp;
while (lp != NULL) { while (lp != NULL) {
lp = lp->loc_next; struct ddloc *nextlp;
if (lp != NULL && lp->loc_dirp == dirp) {
prevlp->loc_next = lp->loc_next; nextlp = lp->loc_next;
if (lp->loc_dirp == dirp) {
prevlp->loc_next = nextlp;
free((caddr_t)lp); free((caddr_t)lp);
lp = prevlp;
} }
else else
prevlp = lp; prevlp = lp;
lp = nextlp;
} }
dd_hash[i] = head.loc_next;
} }
#ifdef HAVE_DD_LOCK #ifdef HAVE_DD_LOCK
__lock_release(dd_hash_lock); __lock_release(dd_hash_lock);