summaryrefslogtreecommitdiff
path: root/svtools/source/svrtf
diff options
context:
space:
mode:
Diffstat (limited to 'svtools/source/svrtf')
-rw-r--r--svtools/source/svrtf/parrtf.cxx9
1 files changed, 7 insertions, 2 deletions
diff --git a/svtools/source/svrtf/parrtf.cxx b/svtools/source/svrtf/parrtf.cxx
index 8b5ad0a0a7cb..a11ec870cf4b 100644
--- a/svtools/source/svrtf/parrtf.cxx
+++ b/svtools/source/svrtf/parrtf.cxx
@@ -20,6 +20,8 @@
#include <sal/config.h>
#include <sal/log.hxx>
+#include <comphelper/scopeguard.hxx>
+
#include <rtl/character.hxx>
#include <rtl/strbuf.hxx>
#include <rtl/tencinfo.h>
@@ -583,9 +585,12 @@ SvParserState SvRTFParser::CallParser()
if( '{' == GetNextToken() && RTF_RTF == GetNextToken() )
{
AddFirstRef();
+ // call ReleaseRef at end of this scope, even in the face of exceptions
+ comphelper::ScopeGuard g([this] {
+ if( SvParserState::Pending != eState )
+ ReleaseRef(); // now parser is not needed anymore
+ });
Continue( 0 );
- if( SvParserState::Pending != eState )
- ReleaseRef(); // now parser is not needed anymore
}
else
eState = SvParserState::Error;