1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:37:35 +00:00

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

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;
}