summaryrefslogtreecommitdiff
path: root/sc/source/core/tool
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2021-10-06 12:57:15 +0200
committerLuboš Luňák <l.lunak@collabora.com>2021-10-06 16:31:35 +0200
commite7ec79fe36a0f22f10167806da80e3c1f30b36e8 (patch)
treef351d73c0486d88a2ab6d56079ed1bd94d34e865 /sc/source/core/tool
parenta693009c28059435ea5bae6d89a76e2243fe7793 (diff)
ScRangeList::UpdateReference() join all ranges properly (tdf#140901)
This is basically a revert of 6eb8634a9f62bfe486ecd2f46, which made this Join() just the last range, probably under the assumption that the function is always called with just one range to update, or to avoid the possibility that Join() removes several items from the list, breaking the next step of the loop. But DeleteArea() may split several ranges, so we need to make sure to Join() all of them. Change-Id: Iea124142335ccdc8fa578344cddce8670c27573d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123135 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'sc/source/core/tool')
-rw-r--r--sc/source/core/tool/rangelst.cxx10
1 files changed, 9 insertions, 1 deletions
diff --git a/sc/source/core/tool/rangelst.cxx b/sc/source/core/tool/rangelst.cxx
index d1b7e598c67e..c1b149d7aee5 100644
--- a/sc/source/core/tool/rangelst.cxx
+++ b/sc/source/core/tool/rangelst.cxx
@@ -436,7 +436,15 @@ bool ScRangeList::UpdateReference(
if( nDx < 0 || nDy < 0 )
{
size_t n = maRanges.size();
- Join(maRanges[n-1], true);
+ for(size_t i = n-1; i > 0;)
+ {
+ Join(maRanges[i], true);
+ // Join() may merge and remove even more than one item, protect against it.
+ if(i >= maRanges.size())
+ i = maRanges.size()-1;
+ else
+ --i;
+ }
}
}