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.
This commit is contained in:
Jean-Marc Lasgouttes 2017-03-01 17:35:05 +01:00
parent 1f10969bb5
commit 5453e00cfa

View File

@ -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();
}