diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2021-09-13 11:29:37 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-09-15 06:08:27 +0200 |
commit | 96bd77de5ad7b7a13f7e48e0f95c05ef49255aa0 (patch) | |
tree | 4c79c57712124a8589c9e6579b6ec7fec9200c3b /forms | |
parent | 3f65724ec5fc92d5a0078a99932358ef7091435c (diff) |
Use <comphelper/servicehelper.hxx> implementing XUnoTunnel part 5
- Revise uses of getSomething to use getFromUnoTunnel
Where that is impossible, use getSomething_cast to unify casting,
and minimize number of places doing low-level transformations.
The change keeps the existing tunnel references that last for the
duration of the pointers' life, because sometimes destroying such
reference may destroy the pointed object, and result in use after
free.
Change-Id: I291c33223582c34cd2c763aa8aacf0ae899ca4c0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122101
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'forms')
-rw-r--r-- | forms/source/richtext/richtextmodel.cxx | 2 | ||||
-rw-r--r-- | forms/source/xforms/xpathlib/xpathlib.cxx | 6 |
2 files changed, 5 insertions, 3 deletions
diff --git a/forms/source/richtext/richtextmodel.cxx b/forms/source/richtext/richtextmodel.cxx index 7498a4a9d2b8..3b78baa524e0 100644 --- a/forms/source/richtext/richtextmodel.cxx +++ b/forms/source/richtext/richtextmodel.cxx @@ -512,7 +512,7 @@ namespace frm { try { - pEngine = reinterpret_cast<RichTextEngine*>(xTunnel->getSomething(getUnoTunnelId())); + pEngine = comphelper::getSomething_cast<RichTextEngine>(xTunnel->getSomething(getUnoTunnelId())); } catch( const Exception& ) { diff --git a/forms/source/xforms/xpathlib/xpathlib.cxx b/forms/source/xforms/xpathlib/xpathlib.cxx index 68cb43a6cdba..12a955639538 100644 --- a/forms/source/xforms/xpathlib/xpathlib.cxx +++ b/forms/source/xforms/xpathlib/xpathlib.cxx @@ -19,6 +19,8 @@ #include <string.h> + +#include <comphelper/servicehelper.hxx> #include <sal/types.h> #include <rtl/ustring.hxx> #include <rtl/string.hxx> @@ -493,7 +495,7 @@ void xforms_instanceFunction(xmlXPathParserContextPtr ctxt, int nargs) try { // xmlXPathObjectPtr xmlXPathNewNodeSet (xmlNodePtr val); Reference< XUnoTunnel > aTunnel(aInstance, UNO_QUERY_THROW); - xmlNodePtr pNode = reinterpret_cast< xmlNodePtr >( aTunnel->getSomething(Sequence< sal_Int8 >()) ); + xmlNodePtr pNode = comphelper::getSomething_cast<xmlNode>(aTunnel->getSomething(Sequence<sal_Int8>())); xmlXPathObjectPtr pObject = xmlXPathNewNodeSet(pNode); xmlXPathReturnNodeSet(ctxt, pObject->nodesetval); } catch (const RuntimeException&) @@ -520,7 +522,7 @@ void xforms_currentFunction(xmlXPathParserContextPtr ctxt, int nargs) { try { Reference< XUnoTunnel > aTunnel(aNode, UNO_QUERY_THROW); - xmlNodePtr pNode = reinterpret_cast< xmlNodePtr >( aTunnel->getSomething(Sequence< sal_Int8 >()) ); + xmlNodePtr pNode = comphelper::getSomething_cast<xmlNode>(aTunnel->getSomething(Sequence<sal_Int8>())); xmlXPathObjectPtr pObject = xmlXPathNewNodeSet(pNode); xmlXPathReturnNodeSet(ctxt, pObject->nodesetval); } |