diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-04-18 12:11:09 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-04-18 12:21:43 +0100 |
commit | 71e71d4b5a9e8f92fc6cdb743d960145600aee46 (patch) | |
tree | 690e96b387056371ba81f064025d7d63dc3f0abd /sw | |
parent | 635823696f07956dda22bcc584bd4a133476710c (diff) |
coverity#1202830 Out-of-bounds access
Change-Id: I25edea176b69c1c1f87bdbff790a39298a813660
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/edit/editsh.cxx | 21 |
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); |