summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2014-04-18 12:11:09 +0100
committerCaolán McNamara <caolanm@redhat.com>2014-04-18 12:21:43 +0100
commit71e71d4b5a9e8f92fc6cdb743d960145600aee46 (patch)
tree690e96b387056371ba81f064025d7d63dc3f0abd /sw
parent635823696f07956dda22bcc584bd4a133476710c (diff)
coverity#1202830 Out-of-bounds access
Change-Id: I25edea176b69c1c1f87bdbff790a39298a813660
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/edit/editsh.cxx21
1 files changed, 17 insertions, 4 deletions
diff --git a/sw/source/core/edit/editsh.cxx b/sw/source/core/edit/editsh.cxx
index 8f2d13ae6d9d..dde9409d7499 100644
--- a/sw/source/core/edit/editsh.cxx
+++ b/sw/source/core/edit/editsh.cxx
@@ -798,12 +798,25 @@ void SwEditShell::SetNumberingRestart()
SwTxtNode* pTxtNd( static_cast<SwTxtNode*>(pNd) );
SwNumRule* pNumRule( pTxtNd->GetNumRule() );
- if ( pNumRule && pTxtNd->GetNum() &&
+ bool bIsNodeNum =
+ ( pNumRule && pTxtNd->GetNum() &&
( pTxtNd->HasNumber() || pTxtNd->HasBullet() ) &&
pTxtNd->IsCountedInList() &&
- !pTxtNd->IsListRestart() &&
- pTxtNd->GetNum()->GetNumber() ==
- pNumRule->Get( static_cast<sal_uInt16>(pTxtNd->GetActualListLevel()) ).GetStart() )
+ !pTxtNd->IsListRestart() );
+ if (bIsNodeNum)
+ {
+ int nListLevel = pTxtNd->GetActualListLevel();
+
+ if (nListLevel < 0)
+ nListLevel = 0;
+
+ if (nListLevel >= MAXLEVEL)
+ nListLevel = MAXLEVEL - 1;
+
+ bIsNodeNum = pTxtNd->GetNum()->GetNumber() ==
+ pNumRule->Get( static_cast<sal_uInt16>(nListLevel) ).GetStart();
+ }
+ if (bIsNodeNum)
{
// now set a the start value as attribute
SwPosition aCurrentNode(*pNd);