[Libreoffice-commits] core.git: Branch 'libreoffice-6-0' - sc/source
Eike Rathke
erack at redhat.com
Mon Feb 26 10:41:52 UTC 2018
sc/source/core/data/table1.cxx | 25 ++++++++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)
New commits:
commit a16ecbb7a23ef639e3a164383e777ee0eccb399b
Author: Eike Rathke <erack at redhat.com>
Date: Wed Feb 21 14:53:06 2018 +0100
Limit ScColumnsRange::Iterator to available columns within bounds
Change-Id: Id5481a975dce99a51cc5619e200e5ea46ad3ad1b
Reviewed-on: https://gerrit.libreoffice.org/50106
Reviewed-by: Eike Rathke <erack at redhat.com>
Tested-by: Jenkins <ci at libreoffice.org>
(cherry picked from commit 6fc75b669438728ba6a4e55d53a79fa0cf006529)
Reviewed-on: https://gerrit.libreoffice.org/50125
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 7b275495eb3b..4ce1306258f1 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -2396,9 +2396,28 @@ const ScConditionalFormatList* ScTable::GetCondFormList() const
ScColumnsRange ScTable::GetColumnsRange(SCCOL nColBegin, SCCOL nColEnd) const
{
- // because the range is inclusive, some code will pass nColEnd<nColBegin to indicate an empty range
- return ScColumnsRange(ScColumnsRange::Iterator(aCol.begin() + nColBegin),
- ScColumnsRange::Iterator(nColEnd < nColBegin ? (aCol.begin() + nColBegin) : (aCol.begin() + nColEnd + 1)));
+ // Because the range is inclusive, some code will pass nColEnd<nColBegin to
+ // indicate an empty range. Ensure that we create only valid iterators for
+ // the range, limit columns to bounds.
+ SCCOL nEffBegin, nEffEnd;
+ if (nColBegin <= nColEnd)
+ {
+ if (nColBegin < 0)
+ nEffBegin = 0;
+ else
+ nEffBegin = std::min<SCCOL>( nColBegin, aCol.size());
+ if (nColEnd < 0)
+ nEffEnd = 0;
+ else
+ nEffEnd = std::min<SCCOL>( nColEnd + 1, aCol.size());
+ }
+ else
+ {
+ // Any empty will do.
+ nEffBegin = nEffEnd = 0;
+ }
+ return ScColumnsRange( ScColumnsRange::Iterator( aCol.begin() + nEffBegin),
+ ScColumnsRange::Iterator( aCol.begin() + nEffEnd));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list