diff options
author | Eike Rathke <ooo@erack.de> | 2011-08-10 21:40:56 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@suse.com> | 2011-08-10 21:43:25 -0400 |
commit | e1db64e6b2dc5380d56877b3de94c46fcbbdde46 (patch) | |
tree | d758876d10a67997775f25b1095ccfca06c0270d | |
parent | ad94add23d30a0a496ef8105f6f8166a93a87178 (diff) |
Prevent crash at column row boundaries.
Modified from the original patch submitted by Olivier Hallot.
Signed-off-by: Kohei Yoshida <kohei.yoshida@suse.com>
-rw-r--r-- | sc/source/ui/view/tabview2.cxx | 46 |
1 files changed, 16 insertions, 30 deletions
diff --git a/sc/source/ui/view/tabview2.cxx b/sc/source/ui/view/tabview2.cxx index e0a808d9a..d755e5415 100644 --- a/sc/source/ui/view/tabview2.cxx +++ b/sc/source/ui/view/tabview2.cxx @@ -633,53 +633,39 @@ void moveCursorByProtRule( if (nMovX > 0) { - if (rCol < MAXCOL) + for (SCCOL i = 0; i < nMovX && rCol < MAXCOL; ++i) { - for (SCCOL i = 0; i < nMovX; ++i) - { - if (!isCellQualified(pDoc, rCol+1, rRow, nTab, bSelectLocked, bSelectUnlocked)) - break; - ++rCol; - } + if (!isCellQualified(pDoc, rCol+1, rRow, nTab, bSelectLocked, bSelectUnlocked)) + break; + ++rCol; } } else if (nMovX < 0) { - if (rCol > 0) + for (SCCOL i = 0; i > nMovX && rCol > 0; --i) { - nMovX = -nMovX; - for (SCCOL i = 0; i < nMovX; ++i) - { - if (!isCellQualified(pDoc, rCol-1, rRow, nTab, bSelectLocked, bSelectUnlocked)) - break; - --rCol; - } + if (!isCellQualified(pDoc, rCol-1, rRow, nTab, bSelectLocked, bSelectUnlocked)) + break; + --rCol; } } if (nMovY > 0) { - if (rRow < MAXROW) + for (SCROW i = 0; i < nMovY && rRow < MAXROW; ++i) { - for (SCROW i = 0; i < nMovY; ++i) - { - if (!isCellQualified(pDoc, rCol, rRow+1, nTab, bSelectLocked, bSelectUnlocked)) - break; - ++rRow; - } + if (!isCellQualified(pDoc, rCol, rRow+1, nTab, bSelectLocked, bSelectUnlocked)) + break; + ++rRow; } } else if (nMovY < 0) { - if (rRow > 0) + for (SCROW i = 0; i > nMovY && rRow > 0; --i) { - nMovY = -nMovY; - for (SCROW i = 0; i < nMovY; ++i) - { - if (!isCellQualified(pDoc, rCol, rRow-1, nTab, bSelectLocked, bSelectUnlocked)) - break; - --rRow; - } + if (!isCellQualified(pDoc, rCol, rRow-1, nTab, bSelectLocked, bSelectUnlocked)) + break; + --rRow; } } } |