Fail Executable_ulfex upon duplicate keys in malformed input
...instead of causing use-after-free of pMergeEntrys, which would be destroyed
during the (non-adding) emplace call but would still be used in the following
if/else block (see the commit message of
c6e2052b6f
"Update git submodules: Fix duplicate
key typo")
Change-Id: Iac8d67e61aba0144d3d5807f478c7b330d7c4c81
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130235
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
@@ -21,7 +21,9 @@
|
|||||||
#include <sal/log.hxx>
|
#include <sal/log.hxx>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <cstdlib>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -298,7 +300,11 @@ void MergeDataFile::InsertEntry(
|
|||||||
if( !pMergeEntrys )
|
if( !pMergeEntrys )
|
||||||
{
|
{
|
||||||
pMergeEntrys = new MergeEntrys;
|
pMergeEntrys = new MergeEntrys;
|
||||||
aMap.emplace( sKey, std::unique_ptr<MergeEntrys>(pMergeEntrys) );
|
if (!aMap.emplace( sKey, std::unique_ptr<MergeEntrys>(pMergeEntrys) ).second)
|
||||||
|
{
|
||||||
|
std::cerr << "Duplicate entry " << sKey << "\n";
|
||||||
|
std::exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user