From ba09d2599d8396a4a8cd961ccd6e26483dd69232 Mon Sep 17 00:00:00 2001 From: Maarten ter Huurne Date: Sun, 17 Aug 2014 10:22:09 +0200 Subject: [PATCH] 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. --- src/filelister.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/filelister.cpp b/src/filelister.cpp index 54af556..cfe278f 100644 --- a/src/filelister.cpp +++ b/src/filelister.cpp @@ -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) {