[Libreoffice-commits] core.git: Branch 'libreoffice-6-0' - starmath/source

Caolán McNamara caolanm at redhat.com
Tue Dec 5 16:04:10 UTC 2017


 starmath/source/mathmlimport.cxx |   17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

New commits:
commit 4963ea48961c7c4dc941c89afe56a1f84b31e66e
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Dec 1 17:33:20 2017 +0000

    ofz#4531 Bad-cast
    
    Change-Id: I152c2e7fa09fc637b176482de9718cf03880c23e
    Reviewed-on: https://gerrit.libreoffice.org/45876
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    Tested-by: Michael Stahl <mstahl at redhat.com>

diff --git a/starmath/source/mathmlimport.cxx b/starmath/source/mathmlimport.cxx
index e1537bf62d75..e252ee166a2b 100644
--- a/starmath/source/mathmlimport.cxx
+++ b/starmath/source/mathmlimport.cxx
@@ -2637,10 +2637,9 @@ void SmXMLTableContext_Impl::EndElement()
     auto nRows = rNodeStack.size()-nElementCount;
     sal_uInt16 nCols = 0;
 
-    SmStructureNode *pArray;
     for (auto i=nRows;i > 0;i--)
     {
-        pArray = static_cast<SmStructureNode *>(rNodeStack.front().release());
+        SmNode* pArray = rNodeStack.front().release();
         rNodeStack.pop_front();
         if (pArray->GetNumSubNodes() == 0)
         {
@@ -2656,22 +2655,24 @@ void SmXMLTableContext_Impl::EndElement()
             aRelationArray.resize(1);
             aRelationArray[0] = pArray;
             SmToken aDummy;
-            pArray = new SmExpressionNode(aDummy);
-            pArray->SetSubNodes(aRelationArray);
+            SmExpressionNode* pExprNode = new SmExpressionNode(aDummy);
+            pExprNode->SetSubNodes(aRelationArray);
+            pArray = pExprNode;
         }
 
         if (pArray->GetNumSubNodes() > nCols)
             nCols = pArray->GetNumSubNodes();
-        aReverseStack.push_front(std::unique_ptr<SmStructureNode>(pArray));
+        aReverseStack.push_front(std::unique_ptr<SmNode>(pArray));
     }
     aExpressionArray.resize(nCols*nRows);
     size_t j=0;
     while ( !aReverseStack.empty() )
     {
-        pArray = static_cast<SmStructureNode *>(aReverseStack.front().release());
+        std::unique_ptr<SmStructureNode> xArray(static_cast<SmStructureNode*>(aReverseStack.front().release()));
         aReverseStack.pop_front();
-        for (sal_uInt16 i=0;i<pArray->GetNumSubNodes();i++)
-            aExpressionArray[j++] = pArray->GetSubNode(i);
+        for (sal_uInt16 i = 0; i < xArray->GetNumSubNodes(); ++i)
+            aExpressionArray[j++] = xArray->GetSubNode(i);
+        xArray->SetSubNodes(SmNodeArray());
     }
 
     SmToken aToken;


More information about the Libreoffice-commits mailing list