[Libreoffice-commits] core.git: svtools/source sw/source

Caolán McNamara caolanm at redhat.com
Tue Dec 12 13:45:22 UTC 2017


 svtools/source/svhtml/parhtml.cxx |   26 +++++++++++++++++++++++---
 sw/source/filter/html/htmltab.cxx |    3 +++
 2 files changed, 26 insertions(+), 3 deletions(-)

New commits:
commit 4fe154d6e068aa9accdb64e8ebd4d1491b6c94f9
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Dec 11 15:19:18 2017 +0000

    ensure dec ref if exception called
    
    Change-Id: I7aabfd98e89389e15bf7b78abb81d3385fe30342
    Reviewed-on: https://gerrit.libreoffice.org/46245
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/svtools/source/svhtml/parhtml.cxx b/svtools/source/svhtml/parhtml.cxx
index ec8f7f5db683..9e5974ae5d40 100644
--- a/svtools/source/svhtml/parhtml.cxx
+++ b/svtools/source/svhtml/parhtml.cxx
@@ -237,6 +237,27 @@ HTMLParser::~HTMLParser()
 {
 }
 
+namespace
+{
+    class RefGuard
+    {
+    private:
+        HTMLParser& m_rParser;
+    public:
+        RefGuard(HTMLParser& rParser)
+            : m_rParser(rParser)
+        {
+            m_rParser.AddFirstRef();
+        }
+
+        ~RefGuard()
+        {
+            if (m_rParser.GetStatus() != SvParserState::Pending)
+                m_rParser.ReleaseRef(); // Parser not needed anymore
+        }
+    };
+}
+
 SvParserState HTMLParser::CallParser()
 {
     eState = SvParserState::Working;
@@ -246,10 +267,9 @@ SvParserState HTMLParser::CallParser()
     nPre_LinePos = 0;
     bPre_IgnoreNewPara = false;
 
-    AddFirstRef();
+    RefGuard aRefGuard(*this);
+
     Continue( HtmlTokenId::NONE );
-    if( SvParserState::Pending != eState )
-        ReleaseRef();       // Parser not needed anymore
 
     return eState;
 }
diff --git a/sw/source/filter/html/htmltab.cxx b/sw/source/filter/html/htmltab.cxx
index 84e7b3b31a2f..5680ca23b932 100644
--- a/sw/source/filter/html/htmltab.cxx
+++ b/sw/source/filter/html/htmltab.cxx
@@ -2717,7 +2717,10 @@ const SwStartNode *SwHTMLParser::InsertTableSection( sal_uInt16 nPoolId )
     {
         SwTableNode *pTableNd = pNd->FindTableNode();
         if (!pTableNd)
+        {
+            eState = SvParserState::Error;
             throw std::runtime_error("missing table");
+        }
         if( pTableNd->GetTable().GetHTMLTableLayout() )
         { // if there is already a HTMTableLayout, this table is already finished
           // and we have to look for the right table in the environment


More information about the Libreoffice-commits mailing list