[Libreoffice-commits] core.git: svtools/source
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Wed Jun 23 15:49:50 UTC 2021
svtools/source/svrtf/parrtf.cxx | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
New commits:
commit d8836d491a6fdf85d4b8df4952962fc6395f02c3
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Jun 23 14:23:52 2021 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Jun 23 17:49:03 2021 +0200
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 at redhat.com>
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;
More information about the Libreoffice-commits
mailing list