diff --git a/sources/Parser/ParserYaml.cpp b/sources/Parser/ParserYaml.cpp index b2e56658..020e7190 100644 --- a/sources/Parser/ParserYaml.cpp +++ b/sources/Parser/ParserYaml.cpp @@ -281,8 +281,12 @@ namespace BBM { std::string subStr; try { - auto start = line.find('[', 0) + 1; - subStr = line.substr(start, line.find(']', 0) - 1 - start); + auto start = line.find('[') + 1; + auto end = line.find(']'); + if (start == std::string::npos || end == std::string::npos || line.back() != ']') { + throw ParserError("Error parsing position."); + } + subStr = line.substr(start, end - start); auto pos = Utils::splitStr(subStr, ','); if (pos.size() != 3) throw (ParserError("Error parsing position.")); diff --git a/sources/Utils/Utils.cpp b/sources/Utils/Utils.cpp index ac20f278..e7ac109b 100644 --- a/sources/Utils/Utils.cpp +++ b/sources/Utils/Utils.cpp @@ -85,6 +85,9 @@ namespace BBM while (std::getline(f, buffer, delim)) {; strings.push_back(buffer); } + if (str.back() == delim) { + strings.emplace_back(""); + } return strings; }