From: Jean-Marc Lasgouttes Date: Wed, 1 Mar 2017 16:35:05 +0000 (+0100) Subject: Do not return a reference to a temporary variable X-Git-Tag: 2.3.0alpha1~294 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=5453e00cfa1f4974301f42ad238884b9ec7e7564;p=features.git 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. --- diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 4cbf227901..f20078bdff 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -3305,8 +3305,12 @@ bool BufferParams::addCiteEngine(vector const & engine) string const & BufferParams::defaultBiblioStyle() const { - map bs = documentClass().defaultBiblioStyle(); - return bs[theCiteEnginesList.getTypeAsString(citeEngineType())]; + map const & bs = documentClass().defaultBiblioStyle(); + auto cit = bs.find(theCiteEnginesList.getTypeAsString(citeEngineType())); + if (cit != bs.end()) + return cit->second; + else + return empty_string(); }