From 9dae3eac6007ea99fd709b0282738b5f38b645ce Mon Sep 17 00:00:00 2001 From: Bastien Brunnenstein <Meoo@users.noreply.github.com> Date: Thu, 4 Jan 2018 18:09:09 +0100 Subject: [PATCH] Fix error in ConCatPathFileName (#4575) --- include/flatbuffers/stl_emulation.h | 4 ++++ include/flatbuffers/util.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/flatbuffers/stl_emulation.h b/include/flatbuffers/stl_emulation.h index 4ec7bc18..3cb3c76d 100644 --- a/include/flatbuffers/stl_emulation.h +++ b/include/flatbuffers/stl_emulation.h @@ -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]; } diff --git a/include/flatbuffers/util.h b/include/flatbuffers/util.h index 86fbf40b..a9ac01c7 100644 --- a/include/flatbuffers/util.h +++ b/include/flatbuffers/util.h @@ -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) { -- GitLab