LibC: closedir() should free the readdir() buffer and the DIR itself.

This commit is contained in:
Andreas Kling 2019-02-09 09:08:27 +01:00
parent c4e984ca49
commit 8ae7be611a
Notes: sideshowbarker 2024-07-19 15:49:00 +09:00

View file

@ -26,9 +26,12 @@ int closedir(DIR* dirp)
{
if (!dirp || dirp->fd == -1)
return -EBADF;
if (dirp->buffer)
free(dirp->buffer);
int rc = close(dirp->fd);
if (rc == 0)
dirp->fd = -1;
free(dirp);
return rc;
}