From 4d4dfeac7cf8cd14efa15a2c5204afc9af4f680c Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Thu, 14 Dec 2017 18:52:15 +0100 Subject: tdf#100635 sw: fix crash in SwTOXMgr::UpdateOrInsertTOX() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GetAuthBrackets() returns an empty string if the user selects [None], in that case apparently 0 bytes are used, multiple places check for that. Change-Id: I8375621fa553bc780db343ed8a0bd7ecb3c832dc (cherry picked from commit 2993bb634dc9ea66af90671a55a4503843338746) Reviewed-on: https://gerrit.libreoffice.org/46568 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- sw/source/uibase/index/toxmgr.cxx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'sw') diff --git a/sw/source/uibase/index/toxmgr.cxx b/sw/source/uibase/index/toxmgr.cxx index bbd2b293628d..b5b8b31e9198 100644 --- a/sw/source/uibase/index/toxmgr.cxx +++ b/sw/source/uibase/index/toxmgr.cxx @@ -355,8 +355,16 @@ bool SwTOXMgr::UpdateOrInsertTOX(const SwTOXDescription& rDesc, pFType = static_cast( pSh->InsertFieldType(type)); } - pFType->SetPreSuffix(rDesc.GetAuthBrackets()[0], - rDesc.GetAuthBrackets()[1]); + OUString const& rBrackets(rDesc.GetAuthBrackets()); + if (rBrackets.isEmpty()) + { + pFType->SetPreSuffix('\0', '\0'); + } + else + { + assert(rBrackets.getLength() == 2); + pFType->SetPreSuffix(rBrackets[0], rBrackets[1]); + } pFType->SetSequence(rDesc.IsAuthSequence()); SwTOXSortKey rArr[3]; rArr[0] = rDesc.GetSortKey1(); -- cgit