diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2022-02-21 08:09:49 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2022-02-21 09:23:40 +0100 |
commit | 56c4445a8060d8ef6aec78f54ea28f4d7e5a8aa7 (patch) | |
tree | 858baa4fe2f1a1babbde6da81231bcb71eafabdf /l10ntools | |
parent | 846f483dca0f0df0f3d1fd42ba3101e47580d98e (diff) |
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
c6e2052b6f0d281fed334f8c803b1a6486d5b3bc "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>
Diffstat (limited to 'l10ntools')
-rw-r--r-- | l10ntools/source/merge.cxx | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/l10ntools/source/merge.cxx b/l10ntools/source/merge.cxx index 004cffacc494..78334c70c8fe 100644 --- a/l10ntools/source/merge.cxx +++ b/l10ntools/source/merge.cxx @@ -21,7 +21,9 @@ #include <sal/log.hxx> #include <algorithm> +#include <cstdlib> #include <fstream> +#include <iostream> #include <string> #include <vector> @@ -298,7 +300,11 @@ void MergeDataFile::InsertEntry( if( !pMergeEntrys ) { 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); + } } |