summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2013-10-03 11:17:11 +0100
committerCaolán McNamara <caolanm@redhat.com>2013-10-03 13:09:21 +0100
commit6e132589cb9095530662f5d71f5d78dfc8962d5b (patch)
tree2ca68dbccdcaa7e4a605ccdae99ab84cf44eb103 /starmath
parent327701f66251dc56933727cf9a9febc79f4dc8c0 (diff)
CID#735395 potential memory leak
Change-Id: Ica07e23920d751757ab5d14d5216615d5fcdbfd9
Diffstat (limited to 'starmath')
-rw-r--r--starmath/inc/cursor.hxx3
-rw-r--r--starmath/inc/visitors.hxx9
-rw-r--r--starmath/source/caret.cxx3
-rw-r--r--starmath/source/cursor.cxx3
-rw-r--r--starmath/source/visitors.cxx5
5 files changed, 14 insertions, 9 deletions
diff --git a/starmath/inc/cursor.hxx b/starmath/inc/cursor.hxx
index 9f15e05ec985..82c98e43fb1f 100644
--- a/starmath/inc/cursor.hxx
+++ b/starmath/inc/cursor.hxx
@@ -90,8 +90,7 @@ public:
~SmCursor(){
SetClipboard();
- if(pGraph)
- delete pGraph;
+ delete pGraph;
pGraph = NULL;
}
diff --git a/starmath/inc/visitors.hxx b/starmath/inc/visitors.hxx
index 3e74c533fa54..7d452237f424 100644
--- a/starmath/inc/visitors.hxx
+++ b/starmath/inc/visitors.hxx
@@ -318,7 +318,7 @@ class SmCaretPosGraphBuildingVisitor : public SmVisitor
public:
/** Builds a caret position graph for pRootNode */
SmCaretPosGraphBuildingVisitor( SmNode* pRootNode );
- virtual ~SmCaretPosGraphBuildingVisitor() {}
+ virtual ~SmCaretPosGraphBuildingVisitor();
void Visit( SmTableNode* pNode );
void Visit( SmBraceNode* pNode );
void Visit( SmBracebodyNode* pNode );
@@ -346,8 +346,11 @@ public:
void Visit( SmRootSymbolNode* pNode );
void Visit( SmRectangleNode* pNode );
void Visit( SmVerticalBraceNode* pNode );
- SmCaretPosGraph* Graph( ){
- return pGraph;
+ SmCaretPosGraph* takeGraph()
+ {
+ SmCaretPosGraph *pRet = pGraph;
+ pGraph = 0;
+ return pRet;
}
private:
SmCaretPosGraphEntry* pRightMost;
diff --git a/starmath/source/caret.cxx b/starmath/source/caret.cxx
index 524ae9efa240..9f9e8f6abc51 100644
--- a/starmath/source/caret.cxx
+++ b/starmath/source/caret.cxx
@@ -39,8 +39,7 @@ SmCaretPosGraphEntry* SmCaretPosGraph::Add(SmCaretPosGraphEntry entry){
}
SmCaretPosGraph::~SmCaretPosGraph(){
- if(pNext)
- delete pNext;
+ delete pNext;
pNext = NULL;
}
diff --git a/starmath/source/cursor.cxx b/starmath/source/cursor.cxx
index 81b1f597324d..e00ca8109d27 100644
--- a/starmath/source/cursor.cxx
+++ b/starmath/source/cursor.cxx
@@ -120,10 +120,9 @@ void SmCursor::BuildGraph(){
anchor = NULL;
position = NULL;
}
- pGraph = NULL;
//Build the new graph
- pGraph = SmCaretPosGraphBuildingVisitor(pTree).Graph();
+ pGraph = SmCaretPosGraphBuildingVisitor(pTree).takeGraph();
//Restore anchor and position pointers
if(_anchor.IsValid() || _position.IsValid()){
diff --git a/starmath/source/visitors.cxx b/starmath/source/visitors.cxx
index 941739c6fffa..93ea409dde1f 100644
--- a/starmath/source/visitors.cxx
+++ b/starmath/source/visitors.cxx
@@ -990,6 +990,11 @@ SmCaretPosGraphBuildingVisitor::SmCaretPosGraphBuildingVisitor( SmNode* pRootNod
pRootNode->Accept(this);
}
+SmCaretPosGraphBuildingVisitor::~SmCaretPosGraphBuildingVisitor()
+{
+ delete pGraph;
+}
+
void SmCaretPosGraphBuildingVisitor::Visit( SmLineNode* pNode ){
SmNodeIterator it( pNode );
while( it.Next( ) ){