summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-06-23 14:23:52 +0100
committerCaolán McNamara <caolanm@redhat.com>2021-06-23 17:49:03 +0200
commitd8836d491a6fdf85d4b8df4952962fc6395f02c3 (patch)
tree10c30b530c5c9139667e582fffe3e92e03b3c1f6 /svtools
parent623b633f1145466e8d60fff3255f476e6001297b (diff)
ofz#35502 Indirect-leak
Change-Id: Ib5bb8e39821cab4f398389971a6296885e2fa4bf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117735 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svtools')
-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;