From 1a1d67396c33fb768f67d9d1148de3ede205f25b Mon Sep 17 00:00:00 2001 From: Julien Nabet Date: Sat, 26 Oct 2024 12:21:54 +0200 Subject: [PATCH] tdf#163486: PVS: Array overrun is possible Change-Id: Ib4b0984d828927b67200acd24ce4a22f4b0e57e5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175677 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- accessibility/source/extended/textwindowaccessibility.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/accessibility/source/extended/textwindowaccessibility.cxx b/accessibility/source/extended/textwindowaccessibility.cxx index 9021f85af610..a5c35ad4b056 100644 --- a/accessibility/source/extended/textwindowaccessibility.cxx +++ b/accessibility/source/extended/textwindowaccessibility.cxx @@ -1004,15 +1004,15 @@ Document::retrieveCharacterAttributes( // sort the attributes auto nLength = static_cast(aRes.getLength()); - std::unique_ptr pIndices( new sal_Int32[nLength] ); - std::iota(&pIndices[0], &pIndices[nLength], 0); - std::sort(&pIndices[0], &pIndices[nLength], + std::vector pIndices(nLength); + std::iota(pIndices.begin(), pIndices.end(), 0); + std::sort(pIndices.begin(), pIndices.end(), [&aRes](sal_Int32 a, sal_Int32 b) { return aRes[a].Name < aRes[b].Name; }); // create sorted sequences according to index array std::vector aNewValues; aNewValues.reserve(nLength); - std::transform(&pIndices[0], &pIndices[nLength], std::back_inserter(aNewValues), + std::transform(pIndices.begin(), pIndices.end(), std::back_inserter(aNewValues), [&aRes](const sal_Int32 nIdx) -> const css::beans::PropertyValue& { return aRes[nIdx]; }); return comphelper::containerToSequence(aNewValues);