Merge remote-tracking branch 'jjthrash/fix-closedir-crash'

This commit is contained in:
Maxime Coste 2014-04-06 02:58:34 +01:00
commit b01ba59911

View File

@ -275,7 +275,10 @@ std::vector<String> list_files(const String& prefix,
{
kak_assert(dirname.empty() or dirname.back() == '/');
DIR* dir = opendir(dirname.empty() ? "./" : dirname.c_str());
auto closeDir = on_scope_end([=]{ closedir(dir); });
auto closeDir = on_scope_end([=]{
if (dir != NULL)
closedir(dir);
});
std::vector<String> result;
if (not dir)