mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 11:16:55 +00:00
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:
parent
1f10969bb5
commit
5453e00cfa
@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user