File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -299,17 +299,19 @@ std::vector<std::string> WsjcppCore::getListOfFiles(const std::string &sDirname)
299299 return vFiles;
300300 }
301301 DIR *dir = opendir (sDirname .c_str ());
302- struct dirent *entry = readdir (dir);
303- while (entry != NULL ) {
304- if (entry->d_type != DT_DIR) {
305- std::string sDir (entry->d_name );
306- if (sDir != " ." && sDir != " .." ) {
307- vFiles.push_back (sDir );
302+ if (dir != NULL ) {
303+ struct dirent *entry = readdir (dir);
304+ while (entry != NULL ) {
305+ if (entry->d_type != DT_DIR) {
306+ std::string sDir (entry->d_name );
307+ if (sDir != " ." && sDir != " .." ) {
308+ vFiles.push_back (sDir );
309+ }
308310 }
311+ entry = readdir (dir);
309312 }
310- entry = readdir (dir);
313+ closedir (dir);
311314 }
312- closedir (dir);
313315 return vFiles;
314316}
315317
You can’t perform that action at this time.
0 commit comments