diff options
author | Takeshi Abe <tabe@fixedpoint.jp> | 2014-11-03 08:42:02 +0900 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2014-11-03 11:17:19 +0000 |
commit | fe1f258d5b77cd6e6a7483d7cf28195dbfdd62a4 (patch) | |
tree | abc31463da5a52e3f330b3674b79082d686dac35 /starmath | |
parent | d4ca8958859b96cb3dc067c0cdc048f35d4a24a6 (diff) |
fix memory leak of pointers contained in m_aErrDescList
Change-Id: I9fcbdcd54978ccaffa5359c0afb0a1990356c218
Reviewed-on: https://gerrit.libreoffice.org/12205
Reviewed-by: David Tardon <dtardon@redhat.com>
Tested-by: David Tardon <dtardon@redhat.com>
Diffstat (limited to 'starmath')
-rw-r--r-- | starmath/inc/parse.hxx | 4 | ||||
-rw-r--r-- | starmath/source/parse.cxx | 16 |
2 files changed, 8 insertions, 12 deletions
diff --git a/starmath/inc/parse.hxx b/starmath/inc/parse.hxx index 7f59def955a6..376113c9e8b3 100644 --- a/starmath/inc/parse.hxx +++ b/starmath/inc/parse.hxx @@ -27,7 +27,7 @@ #include "types.hxx" -#include <vector> +#include <boost/ptr_container/ptr_vector.hpp> class SmNode; @@ -157,7 +157,7 @@ struct SmErrorDesc typedef ::std::stack< SmNode* > SmNodeStack; -typedef ::std::vector< SmErrorDesc* > SmErrDescList; +typedef boost::ptr_vector< SmErrorDesc > SmErrDescList; /**************************************************************************/ diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx index 408612e0a185..c1757bf20768 100644 --- a/starmath/source/parse.cxx +++ b/starmath/source/parse.cxx @@ -2406,8 +2406,6 @@ SmNode *SmParser::Parse(const OUString &rBuffer) m_nColOff = 0; m_nCurError = -1; - for ( size_t i = 0, n = m_aErrDescList.size(); i < n; ++i ) - delete m_aErrDescList[ i ]; m_aErrDescList.clear(); while ( !m_aNodeStack.empty() ) @@ -2430,8 +2428,6 @@ SmNode *SmParser::ParseExpression(const OUString &rBuffer) m_nColOff = 0; m_nCurError = -1; - for ( size_t i = 0, n = m_aErrDescList.size(); i < n; ++i ) - delete m_aErrDescList[ i ]; m_aErrDescList.clear(); while ( !m_aNodeStack.empty() ) @@ -2485,11 +2481,11 @@ size_t SmParser::AddError(SmParseError Type, SmNode *pNode) const SmErrorDesc *SmParser::NextError() { if ( !m_aErrDescList.empty() ) - if (m_nCurError > 0) return m_aErrDescList[ --m_nCurError ]; + if (m_nCurError > 0) return &m_aErrDescList[ --m_nCurError ]; else { m_nCurError = 0; - return m_aErrDescList[ m_nCurError ]; + return &m_aErrDescList[ m_nCurError ]; } else return NULL; } @@ -2498,11 +2494,11 @@ const SmErrorDesc *SmParser::NextError() const SmErrorDesc *SmParser::PrevError() { if ( !m_aErrDescList.empty() ) - if (m_nCurError < (int) (m_aErrDescList.size() - 1)) return m_aErrDescList[ ++m_nCurError ]; + if (m_nCurError < (int) (m_aErrDescList.size() - 1)) return &m_aErrDescList[ ++m_nCurError ]; else { m_nCurError = (int) (m_aErrDescList.size() - 1); - return m_aErrDescList[ m_nCurError ]; + return &m_aErrDescList[ m_nCurError ]; } else return NULL; } @@ -2511,10 +2507,10 @@ const SmErrorDesc *SmParser::PrevError() const SmErrorDesc *SmParser::GetError(size_t i) { if ( i < m_aErrDescList.size() ) - return m_aErrDescList[ i ]; + return &m_aErrDescList[ i ]; if ( (size_t)m_nCurError < m_aErrDescList.size() ) - return m_aErrDescList[ m_nCurError ]; + return &m_aErrDescList[ m_nCurError ]; return NULL; } |