diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-11-23 21:21:20 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-11-24 13:17:09 +0100 |
commit | ab58e2e68f969e49b97b28b81225ed1e87df0855 (patch) | |
tree | 8fb94712e9fee24831a30e70df9ed7d1eaec29cf /sc | |
parent | 82c3483b2de5ce197e5a7f7ebaf37139518ea261 (diff) |
ofz#4406: don't increment ScCompressedArray::Iterator past end
Change-Id: I2adc204722a6143384bab8aecd16bed42cb5016a
Reviewed-on: https://gerrit.libreoffice.org/45192
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/data/table2.cxx | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index a45d7af408c2..b7b169e418b8 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -2962,15 +2962,15 @@ sal_uLong ScTable::GetColWidth( SCCOL nStartCol, SCCOL nEndCol ) const bool bHidden = false; SCCOL nLastHiddenCol = -1; auto colWidthIt = mpColWidth->begin() + nStartCol; - for (SCCOL nCol = nStartCol; nCol <= nEndCol; ++nCol, ++colWidthIt) + for (SCCOL nCol = nStartCol; nCol <= nEndCol; ++nCol) { if (nCol > nLastHiddenCol) bHidden = ColHidden(nCol, nullptr, &nLastHiddenCol); - if (bHidden) - continue; + if (!bHidden) + nW += *colWidthIt; - nW += *colWidthIt; + ++colWidthIt; } return nW; } @@ -3406,9 +3406,12 @@ SCCOL ScTable::GetLastChangedCol() const SCCOL nLastFound = 0; auto colWidthIt = mpColWidth->begin() + 1; - for ( SCCOL nCol = 1; nCol < aCol.size(); nCol++, ++colWidthIt ) + for (SCCOL nCol = 1; nCol < aCol.size(); ++nCol) + { if ((mpColFlags->GetValue(nCol) & CRFlags::All) || (*colWidthIt != STD_COL_WIDTH)) nLastFound = nCol; + ++colWidthIt; + } return nLastFound; } @@ -3822,11 +3825,13 @@ sal_uLong ScTable::GetColOffset( SCCOL nCol, bool bHiddenAsZero ) const sal_uLong n = 0; if ( mpColWidth ) { - SCCOL i; auto colWidthIt = mpColWidth->begin(); - for( i = 0; i < nCol; i++, ++colWidthIt ) + for (SCCOL i = 0; i < nCol; ++i) + { if (!( bHiddenAsZero && ColHidden(i) )) n += *colWidthIt; + ++colWidthIt; + } } else { |