From 336d816176650726f6d14539464d9fd28ddd032d Mon Sep 17 00:00:00 2001 From: Eike Rathke Date: Wed, 16 Mar 2016 23:03:58 +0100 Subject: [PATCH] ensure a correct index is assigned to a duplicated ScRangeData instance ScRangeName::insert() assigns an index only if the passed ScRangeData instance's index was 0. Duplicating an ScRangeData object duplicates also the index, so effectively two instances with the same index could be inserted to the named expressions collection, a following ScRangeName::findByIndex() retrieved one of them by chance. Change-Id: Ic141ffb1a683bda5907f4359167da84faf1649e1 --- sc/source/core/data/formulacell.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index a2891aefdf88..c97e330f2fdd 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -468,6 +468,7 @@ void adjustRangeName(formula::FormulaToken* pToken, ScDocument& rNewDoc, const S { bNewGlobal = bOldGlobal; pRangeData = new ScRangeData(*pOldRangeData, &rNewDoc); + pRangeData->SetIndex(0); // needed for insert to assign a new index ScTokenArray* pRangeNameToken = pRangeData->GetCode(); if (rNewDoc.GetPool() != const_cast(pOldDoc)->GetPool()) {