From 404a2ff6222228877087233bbe1f2a1544a46d8a Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 25 Jan 2018 10:18:52 +0000 Subject: ofz#4849 Direct leak MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: If9b7f6de42d99c76165aec775b8cde2505df0c62 Reviewed-on: https://gerrit.libreoffice.org/48561 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- sw/source/filter/html/swhtml.cxx | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'sw') diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx index 4115bb6f9e6b..3cb67e703bef 100644 --- a/sw/source/filter/html/swhtml.cxx +++ b/sw/source/filter/html/swhtml.cxx @@ -674,14 +674,21 @@ void SwHTMLParser::Continue( HtmlTokenId nToken ) EndNumBulList(); OSL_ENSURE( !m_nContextStMin, "There are protected contexts" ); - m_nContextStMin = 0; - while( m_aContexts.size() ) + // try this twice, first normally to let m_nContextStMin decrease + // naturally and get contexts popped in desired order, and if that + // fails force it + for (int i = 0; i < 2; ++i) { - std::unique_ptr xCntxt(PopContext()); - if (xCntxt) + while (m_aContexts.size() > m_nContextStMin) { - EndContext(xCntxt.get()); + std::unique_ptr xCntxt(PopContext()); + if (xCntxt) + EndContext(xCntxt.get()); } + if (!m_nContextStMin) + break; + OSL_ENSURE(!m_nContextStMin, "There are still protected contexts"); + m_nContextStMin = 0; } if( !m_aParaAttrs.empty() ) -- cgit v1.2.3