sc/source/core/data/PivotTableFormatOutput.cxx | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
New commits: commit fbaeeee7ac09846099932c14fe78fb01a1b762b7 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Thu Apr 18 09:38:07 2024 +0100 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Thu Apr 18 20:24:51 2024 +0200 crashtesting: crash on export of forum-mso-en4-470772.xlsx to xlsx similar fix as: commit 1d5630c5deeec5dca724c29ec8c886bfa71a2099 Date: Tue Apr 16 15:21:49 2024 +0900 pivot: add checks that prevent reading out of vector bounds Change-Id: I190da7586cff9c7e8dd4011ad61e68abba6ecd53 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166240 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/sc/source/core/data/PivotTableFormatOutput.cxx b/sc/source/core/data/PivotTableFormatOutput.cxx index cdd2ac90914f..575fd5e77508 100644 --- a/sc/source/core/data/PivotTableFormatOutput.cxx +++ b/sc/source/core/data/PivotTableFormatOutput.cxx @@ -58,16 +58,13 @@ public: { std::vector<OUString> aNames; fillNamesForDimension(aNames, nDimension); - maNameCache.emplace(nDimension, aNames); - return aNames[nIndex]; - } - else - { - std::vector<OUString>& rNames = iterator->second; - if (nIndex >= rNames.size()) - return OUString(); - return rNames[nIndex]; + iterator = maNameCache.emplace(nDimension, aNames).first; } + + const std::vector<OUString>& rNames = iterator->second; + if (nIndex >= rNames.size()) + return OUString(); + return rNames[nIndex]; } };