1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-11-22 13:29:42 +02: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; string slashedPath = path;
if (path[path.length() - 1] != '/') if (!path.empty() && path[path.length() - 1] != '/') {
slashedPath.push_back('/'); slashedPath.push_back('/');
}
DIR *dirp; DIR *dirp;
if ((dirp = opendir(slashedPath.c_str())) == NULL) { if ((dirp = opendir(slashedPath.c_str())) == NULL) {