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 /svtools/source/svhtml | |
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>
Diffstat (limited to 'svtools/source/svhtml')
-rw-r--r-- | svtools/source/svhtml/parhtml.cxx | 26 |
1 files changed, 23 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; } |