summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJimmy Thrasher <jimmy@jimmythrasher.com>2014-04-05 17:59:09 -0400
committerJimmy Thrasher <jimmy@jimmythrasher.com>2014-04-05 18:00:59 -0400
commitfd5406282d0767ddb7609de4790368e168b56aba (patch)
tree87d6b538e1c6a82675acb640a32adbb304d71d34 /src
parentc4e694fb7b747a2659060e7edd3788502a28a291 (diff)
Fix crash caused by attempting to close a nonexistent DIR*
Diffstat (limited to 'src')
-rw-r--r--src/file.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/file.cc b/src/file.cc
index 01fc36c5..653b2083 100644
--- a/src/file.cc
+++ b/src/file.cc
@@ -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)