1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-06-28 12:39:50 +03:00

Avoid out-of-range lookup when FileLister::browse is passed empty string

When the path is the empty string, it is handled as the current working
directory, which is consistent with how relative paths are handled.
This commit is contained in:
Maarten ter Huurne 2014-08-17 10:22:09 +02:00
parent 20725fcdda
commit ba09d2599d

View File

@ -71,8 +71,9 @@ bool FileLister::browse(const string& path, bool clean)
}
string slashedPath = path;
if (path[path.length() - 1] != '/')
if (!path.empty() && path[path.length() - 1] != '/') {
slashedPath.push_back('/');
}
DIR *dirp;
if ((dirp = opendir(slashedPath.c_str())) == NULL) {