Skip to content

Commit 5aca36b

Browse files
author
iyadahmed
committed
Fix memory leaks that were reported by LeakSanitizer on Linux during simple usage
During simple usage of the library, LeakSanitizer reported some leaks related to `opendir`, this commit fixes those leaks
1 parent 3cd893a commit 5aca36b

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

ImGuiFileDialog.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,8 +559,8 @@ class FileSystemDirent : public IGFD::IFileSystem {
559559
// this func will fail
560560
pDir = opendir(vName.c_str());
561561
if (pDir != nullptr) {
562-
return true;
563562
(void)closedir(pDir);
563+
return true;
564564
}
565565
}
566566
return false;
@@ -728,7 +728,12 @@ class FileSystemDirent : public IGFD::IFileSystem {
728728
return res;
729729
}
730730
bool IsDirectory(const std::string& vFilePathName) override {
731-
return (opendir(vFilePathName.c_str()) != nullptr);
731+
DIR *pDir = opendir(vFilePathName.c_str());
732+
if (pDir) {
733+
(void)closedir(pDir);
734+
return true;
735+
}
736+
return false;
732737
}
733738
};
734739
#define FILE_SYSTEM_OVERRIDE FileSystemDirent

0 commit comments

Comments
 (0)