Fix error in ConCatPathFileName (#4575)

This commit is contained in:
Bastien Brunnenstein
2018-01-04 18:09:09 +01:00
committed by Wouter van Oortmerssen
parent 99a8a68a80
commit 9dae3eac60
2 changed files with 5 additions and 1 deletions

View File

@@ -38,6 +38,10 @@ namespace flatbuffers {
// Retrieve ::back() from a string in a way that is compatible with pre C++11
// STLs (e.g stlport).
inline char& string_back(std::string &value) {
return value[value.length() - 1];
}
inline char string_back(const std::string &value) {
return value[value.length() - 1];
}

View File

@@ -216,7 +216,7 @@ inline std::string ConCatPathFileName(const std::string &path,
const std::string &filename) {
std::string filepath = path;
if (filepath.length()) {
char filepath_last_character = string_back(filepath);
char &filepath_last_character = string_back(filepath);
if (filepath_last_character == kPathSeparatorWindows) {
filepath_last_character = kPathSeparator;
} else if (filepath_last_character != kPathSeparator) {