diff options
author | 2021-08-02 00:03:56 +1000 | |
---|---|---|
committer | 2021-08-02 00:03:56 +1000 | |
commit | 0753a9229bdc6682544677f76e4c4ee031be0674 (patch) | |
tree | 03a02b157283353524bc2587c184c44d5c733ae3 /src/lib/formats/fsmgr.cpp | |
parent | 8628ec517633c0053d74e302e6fc62bffa78fe84 (diff) |
formats/fsmgr.cpp: Don't assume string iterators can be indexed (reported by coverity).
Diffstat (limited to 'src/lib/formats/fsmgr.cpp')
-rw-r--r-- | src/lib/formats/fsmgr.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/lib/formats/fsmgr.cpp b/src/lib/formats/fsmgr.cpp index cc18a942ed5..fa48704f935 100644 --- a/src/lib/formats/fsmgr.cpp +++ b/src/lib/formats/fsmgr.cpp @@ -371,10 +371,8 @@ uint32_t filesystem_t::r32l(const uint8_t *p) std::string filesystem_t::trim_end_spaces(const std::string &str) { - auto i = str.end(); - while(i != str.begin() && i[-1] == ' ') - i--; - return std::string(str.begin(), i); + const auto i = str.find_last_not_of(' '); + return str.substr(0, (std::string::npos != i) ? (i + 1) : 0); } filesystem_t::file_t filesystem_t::idir_t::file_create(const fs_meta_data &info) |