Add missing closedir() in readdir() (dotnet/core-setup#5761)
authorOmair Majid <omajid@redhat.com>
Wed, 10 Apr 2019 19:59:37 +0000 (15:59 -0400)
committerVitek Karas <vitek.karas@microsoft.com>
Wed, 10 Apr 2019 19:59:37 +0000 (12:59 -0700)
The readdir function calls opendir() but never closedir(), leaking the
DIR resource.

Commit migrated from https://github.com/dotnet/core-setup/commit/ad2e0c415a04e47be4343cc1e956166bfd244632

src/installer/corehost/common/pal.unix.cpp

index 5b5c42f..e0701d3 100644 (file)
@@ -647,6 +647,8 @@ static void readdir(const pal::string_t& path, const pal::string_t& pattern, boo
                 files.push_back(filepath);
             }
         }
+
+        closedir(dir);
     }
 }