diff --git a/common/CheckPath.h b/common/CheckPath.h index ebbb7c4c..e685b526 100644 --- a/common/CheckPath.h +++ b/common/CheckPath.h @@ -8,13 +8,10 @@ #include "JFJochException.h" inline void CheckPath(const std::string &s) { - if (s.empty()) - throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, - "Path cannot be empty"); - if (s.front() == '/') + if (!s.empty() && s.front() == '/') throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Path cannot start with slash"); - if (s.substr(0,3) == "../") + if (s.size() >= 3 && s.substr(0,3) == "../") throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Path cannot start with ../"); if (s.find("/../") != std::string::npos)