From 8ae7be611adee9bd1bb80fb8cbcce70007f38d47 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 9 Feb 2019 09:08:27 +0100 Subject: [PATCH] LibC: closedir() should free the readdir() buffer and the DIR itself. --- LibC/dirent.cpp | 3 +++ 1 file changed, 3 insertions(+) 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; }