diff options
Diffstat (limited to 'sc/source/core/data/dociter.cxx')
-rw-r--r-- | sc/source/core/data/dociter.cxx | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx index eeeeb9f1cc69..407c5484a4c2 100644 --- a/sc/source/core/data/dociter.cxx +++ b/sc/source/core/data/dociter.cxx @@ -1080,8 +1080,8 @@ void ScQueryCellIterator::InitPos() nRow = mpParam->nRow1; if (mpParam->bHasHeader && mpParam->bByRow) ++nRow; - ScColumn* pCol = &(pDoc->maTabs[nTab])->aCol[nCol]; - maCurPos = pCol->maCells.position(nRow); + const ScColumn& rCol = pDoc->maTabs[nTab]->CreateColumnIfNotExists(nCol); + maCurPos = rCol.maCells.position(nRow); } void ScQueryCellIterator::IncPos() @@ -1799,6 +1799,10 @@ bool ScQueryCellIterator::BinarySearch() if (nTab >= pDoc->GetTableCount()) OSL_FAIL("try to access index out of bounds, FIX IT"); nCol = mpParam->nCol1; + + if (nCol >= pDoc->maTabs[nTab]->GetAllocatedColumnsCount()) + return false; + ScColumn* pCol = &(pDoc->maTabs[nTab])->aCol[nCol]; if (pCol->IsEmptyData()) return false; |