diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-12-11 15:19:18 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-12-12 14:42:42 +0100 |
commit | 4fe154d6e068aa9accdb64e8ebd4d1491b6c94f9 (patch) | |
tree | 38e082ea93e7f6f4c170be63f4f212790371c339 | |
parent | 126b910380d13c91938f8b5d5f398fc5390403e4 (diff) |
ensure dec ref if exception called
Change-Id: I7aabfd98e89389e15bf7b78abb81d3385fe30342
Reviewed-on: https://gerrit.libreoffice.org/46245
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | svtools/source/svhtml/parhtml.cxx | 26 | ||||
-rw-r--r-- | sw/source/filter/html/htmltab.cxx | 3 |
2 files changed, 26 insertions, 3 deletions
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 |