summaryrefslogtreecommitdiff
path: root/LibC/dirent.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-02-09 09:08:27 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-02-09 09:08:27 +0100
commit8ae7be611adee9bd1bb80fb8cbcce70007f38d47 (patch)
treebb5c31748605829efe862884a05021bef1c9a20c /LibC/dirent.cpp
parentc4e984ca492e7ee95b66281bf86c9c58b5cb5392 (diff)
downloadserenity-8ae7be611adee9bd1bb80fb8cbcce70007f38d47.zip
LibC: closedir() should free the readdir() buffer and the DIR itself.
Diffstat (limited to 'LibC/dirent.cpp')
-rw-r--r--LibC/dirent.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/LibC/dirent.cpp b/LibC/dirent.cpp
index 8f70166840..c511b9dad6 100644
--- a/LibC/dirent.cpp
+++ b/LibC/dirent.cpp
@@ -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;
}