commit 5453e00cfa1f4974301f42ad238884b9ec7e7564 Author: Jean-Marc Lasgouttes <lasgout...@lyx.org> Date: Wed Mar 1 17:35:05 2017 +0100
Do not return a reference to a temporary variable Coverity correctly spotted that the existing code creates a temporary map and returns a value from it. It is not possible to make the map const& directly because operator[] may change the map. Therefore, we use map::find instead. --- src/BufferParams.cpp | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 4cbf227..f20078b 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -3305,8 +3305,12 @@ bool BufferParams::addCiteEngine(vector<string> const & engine) string const & BufferParams::defaultBiblioStyle() const { - map<string, string> bs = documentClass().defaultBiblioStyle(); - return bs[theCiteEnginesList.getTypeAsString(citeEngineType())]; + map<string, string> const & bs = documentClass().defaultBiblioStyle(); + auto cit = bs.find(theCiteEnginesList.getTypeAsString(citeEngineType())); + if (cit != bs.end()) + return cit->second; + else + return empty_string(); }