ソースを参照

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

Andreas Kling 6 年 前
コミット
8ae7be611a
1 ファイル変更3 行追加0 行削除
  1. 3 0
      LibC/dirent.cpp

+ 3 - 0
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;
 }