diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-05-10 21:46:53 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-05-10 21:46:53 +0100 |
commit | 75e7643e22bcf674739ca890bfc06f80e872624b (patch) | |
tree | 05e08499021a87fe107621fc8aa2917a23d0d189 /sot | |
parent | a24a980424ec2ec81b13c8e5a95394d62cbf7406 (diff) |
Related: fdo#47644 get out of bounds conditions right
Change-Id: Icac9a8337296f92af5007a051f00388a64955178
Diffstat (limited to 'sot')
-rw-r--r-- | sot/source/sdstor/stgstrms.cxx | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/sot/source/sdstor/stgstrms.cxx b/sot/source/sdstor/stgstrms.cxx index 88bc41630f4b..3ee485e66432 100644 --- a/sot/source/sdstor/stgstrms.cxx +++ b/sot/source/sdstor/stgstrms.cxx @@ -455,17 +455,14 @@ sal_Bool StgStrm::Pos2Page( sal_Int32 nBytePos ) } else { - size_t nBgnDistance = std::distance(m_aPagesCache.begin(), aI); + size_t nBgnIndex = std::distance(m_aPagesCache.begin(), aI); + size_t nIndex = nBgnIndex + nRel; - size_t nIndex = nBgnDistance + nRel; - - if (nIndex > m_aPagesCache.size()) - { - nRel = m_aPagesCache.size() - nBgnDistance; + if (nIndex >= m_aPagesCache.size()) nIndex = m_aPagesCache.size() - 1; - } - else - nRel = 0; + + size_t nSuccessfulStepsTaken = nIndex - nBgnIndex; + nRel -= nSuccessfulStepsTaken; nLast = nIndex ? m_aPagesCache[nIndex - 1] : STG_EOF; nBgn = m_aPagesCache[nIndex]; |