cid#1557088 Data race condition

since:

commit d181d8acbf
CommitDate: Fri Aug 25 12:44:33 2017 +0200

    tdf#84237 use XErrorHandler in CDocumentBuilder

Change-Id: Iac1d2b88f2910298d30de4d12798bb38c36a0de9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174102
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
This commit is contained in:
Caolán McNamara 2024-09-27 21:27:10 +01:00
parent 9bd20c306e
commit 8e02696b32
2 changed files with 14 additions and 11 deletions

View file

@ -254,14 +254,15 @@ namespace DOM
CDocumentBuilder * const pDocBuilder = static_cast<CDocumentBuilder*>(pctx->_private);
if (pDocBuilder->getErrorHandler().is()) // if custom error handler is set (using setErrorHandler ())
Reference<XErrorHandler> xErrorHandler = pDocBuilder->getErrorHandler();
if (xErrorHandler.is()) // if custom error handler is set (using setErrorHandler ())
{
// Prepare SAXParseException to be passed to custom XErrorHandler::warning function
css::xml::sax::SAXParseException saxex(make_error_message(pctx), {}, {}, {}, {},
pctx->lastError.line, pctx->lastError.int2);
// Call custom warning function
pDocBuilder->getErrorHandler()->warning(::css::uno::Any(saxex));
xErrorHandler->warning(::css::uno::Any(saxex));
}
}
catch (const css::uno::Exception &)
@ -284,14 +285,15 @@ namespace DOM
CDocumentBuilder * const pDocBuilder = static_cast<CDocumentBuilder*>(pctx->_private);
if (pDocBuilder->getErrorHandler().is()) // if custom error handler is set (using setErrorHandler ())
Reference<XErrorHandler> xErrorHandler = pDocBuilder->getErrorHandler();
if (xErrorHandler.is()) // if custom error handler is set (using setErrorHandler ())
{
// Prepare SAXParseException to be passed to custom XErrorHandler::error function
css::xml::sax::SAXParseException saxex(make_error_message(pctx), {}, {}, {}, {},
pctx->lastError.line, pctx->lastError.int2);
// Call custom warning function
pDocBuilder->getErrorHandler()->error(::css::uno::Any(saxex));
xErrorHandler->error(::css::uno::Any(saxex));
}
}
catch (const css::uno::Exception &)
@ -412,6 +414,13 @@ namespace DOM
m_xErrorHandler = xEH;
}
Reference< XErrorHandler > CDocumentBuilder::getErrorHandler()
{
std::scoped_lock const g(m_Mutex);
return m_xErrorHandler;
}
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*

View file

@ -104,7 +104,6 @@ namespace DOM
/// @throws css::uno::RuntimeException
css::uno::Reference< css::xml::sax::XEntityResolver > getEntityResolver();
/**
Specify the ErrorHandler to be used to report errors present in
the XML document to be parsed.
@ -115,12 +114,7 @@ namespace DOM
Get the ErrorHandler to be used to report errors present in
the XML document to be parsed.
*/
const css::uno::Reference< css::xml::sax::XErrorHandler >& getErrorHandler() const
{
return m_xErrorHandler;
}
css::uno::Reference< css::xml::sax::XErrorHandler > getErrorHandler();
};
}