sw/inc/ndhints.hxx | 24 ++++++++++++++++++------ sw/source/core/txtnode/ndhints.cxx | 4 ++++ 2 files changed, 22 insertions(+), 6 deletions(-)
New commits: commit 4fcde4fe8ea5d4521a59e19291e393835144d7d9 Author: Ashod Nakashian <ashodnakash...@yahoo.com> Date: Fri Jan 9 11:08:58 2015 -0500 Hint assertions and sanity checks added. Change-Id: I83bf8866c8855b3266703eca62010d28388c5a07 Reviewed-on: https://gerrit.libreoffice.org/13880 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/sw/inc/ndhints.hxx b/sw/inc/ndhints.hxx index 4bfbd1f..1202b7b 100644 --- a/sw/inc/ndhints.hxx +++ b/sw/inc/ndhints.hxx @@ -103,13 +103,25 @@ public: SwTxtAttr * Cut( const size_t nPosInStart ); inline const SwTxtAttr * GetStart( const size_t nPos ) const - { return m_HintStarts[nPos]; } + { + assert(nPos < m_HintStarts.size()); + return m_HintStarts[nPos]; + } inline const SwTxtAttr * GetEnd( const size_t nPos ) const - { return m_HintEnds [nPos]; } + { + assert(nPos < m_HintEnds.size()); + return m_HintEnds[nPos]; + } inline SwTxtAttr * GetStart( const size_t nPos ) - { return m_HintStarts[nPos]; } + { + assert(nPos < m_HintStarts.size()); + return m_HintStarts[nPos]; + } inline SwTxtAttr * GetEnd( const size_t nPos ) - { return m_HintEnds [nPos]; } + { + assert(nPos < m_HintStarts.size()); + return m_HintEnds[nPos]; + } inline size_t GetEndCount() const { return m_HintEnds.size(); } inline size_t GetStartCount() const { return m_HintStarts.size(); } @@ -122,8 +134,8 @@ public: inline SwTxtAttr * GetTextHint( const size_t nIdx ) { return GetStart(nIdx); } inline const SwTxtAttr * operator[]( const size_t nIdx ) const - { return m_HintStarts[nIdx]; } - inline size_t Count() const { return m_HintStarts.size(); } + { return GetStart(nIdx); } + inline size_t Count() const { return GetStartCount(); } #ifdef DBG_UTIL bool Check(bool) const; diff --git a/sw/source/core/txtnode/ndhints.cxx b/sw/source/core/txtnode/ndhints.cxx index 5f1d84c..3808008 100644 --- a/sw/source/core/txtnode/ndhints.cxx +++ b/sw/source/core/txtnode/ndhints.cxx @@ -132,6 +132,10 @@ void SwpHintsArray::DeleteAtPos( const size_t nPos ) bool SwpHintsArray::Contains( const SwTxtAttr *pHt ) const { +#ifdef DBG_UTIL + Check(true); +#endif + // DO NOT use find() here! // if called from SwTxtNode::InsertItem, pHt has already been deleted, // so it cannot be dereferenced
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits