summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-12-11 15:19:18 +0000
committerCaolán McNamara <caolanm@redhat.com>2017-12-12 14:42:42 +0100
commit4fe154d6e068aa9accdb64e8ebd4d1491b6c94f9 (patch)
tree38e082ea93e7f6f4c170be63f4f212790371c339 /svtools
parent126b910380d13c91938f8b5d5f398fc5390403e4 (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')
-rw-r--r--svtools/source/svhtml/parhtml.cxx26
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;
}