Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
unix: revert "eio: fix memory leak in eio__scandir()"
Browse files Browse the repository at this point in the history
This reverts commit b450d87.

It turns out that libeio doesn't actually leak memory but it does do an
unnecessary (and confusing!) allocation that is not free'd until after
the user callback returns.
  • Loading branch information
bnoordhuis committed Sep 14, 2011
1 parent 4b9b692 commit 337ff16
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 13 deletions.
12 changes: 1 addition & 11 deletions src/unix/eio/eio.c
Expand Up @@ -1812,17 +1812,7 @@ eio__scandir (eio_req *req, etp_worker *self)
#endif

if (req->flags & EIO_FLAG_PTR1_FREE)
{
req->flags &= ~EIO_FLAG_PTR1_FREE;
free (req->ptr1);
req->ptr1 = NULL;
}

if (!dirp)
{
req->errorno = errno;
return;
}
free (req->ptr1);

req->flags |= EIO_FLAG_PTR1_FREE | EIO_FLAG_PTR2_FREE;
req->ptr1 = dents = flags ? malloc (dentalloc * sizeof (eio_dirent)) : 0;
Expand Down
2 changes: 0 additions & 2 deletions src/unix/fs.c
Expand Up @@ -123,8 +123,6 @@ static int uv__fs_after(eio_req* eio) {
* callback. We must keep it until uv_fs_req_cleanup. If we get rid of
* libeio this can be avoided.
*/
if (req->eio->ptr2 == NULL)
break;
buflen = 0;
name = req->eio->ptr2;
for (i = 0; i < req->result; i++) {
Expand Down

0 comments on commit 337ff16

Please sign in to comment.