[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - starmath/source

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


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

New commits:
commit 328f3e7e4c67bf2e09a56f199a4332f1b1fe3b11
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/45877
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>

diff --git a/starmath/source/mathmlimport.cxx b/starmath/source/mathmlimport.cxx
index b97ec1be70f6..6644e7f65add 100644
--- a/starmath/source/mathmlimport.cxx
+++ b/starmath/source/mathmlimport.cxx
@@ -2676,10 +2676,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)
         {
@@ -2695,22 +2694,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