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 /package/source/zippackage/ZipPackageFolder.cxx | |
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 'package/source/zippackage/ZipPackageFolder.cxx')
-rw-r--r-- | package/source/zippackage/ZipPackageFolder.cxx | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/package/source/zippackage/ZipPackageFolder.cxx b/package/source/zippackage/ZipPackageFolder.cxx index 4c94a78abed9..5ea4213f95fd 100644 --- a/package/source/zippackage/ZipPackageFolder.cxx +++ b/package/source/zippackage/ZipPackageFolder.cxx @@ -164,19 +164,10 @@ void SAL_CALL ZipPackageFolder::insertByName( const OUString& aName, const uno:: if ( !(aElement >>= xRef) ) throw IllegalArgumentException(THROW_WHERE, uno::Reference< uno::XInterface >(), 0 ); - sal_Int64 nTest; - ZipPackageEntry *pEntry; - if ( ( nTest = xRef->getSomething ( ZipPackageFolder::getUnoTunnelId() ) ) != 0 ) - { - ZipPackageFolder *pFolder = reinterpret_cast < ZipPackageFolder * > ( nTest ); - pEntry = pFolder; - } - else if ( ( nTest = xRef->getSomething ( ZipPackageStream::getUnoTunnelId() ) ) != 0 ) - { - ZipPackageStream *pStream = reinterpret_cast < ZipPackageStream * > ( nTest ); - pEntry = pStream; - } - else + ZipPackageEntry* pEntry = comphelper::getFromUnoTunnel<ZipPackageFolder>(xRef); + if (!pEntry) + pEntry = comphelper::getFromUnoTunnel<ZipPackageStream>(xRef); + if (!pEntry) throw IllegalArgumentException(THROW_WHERE, uno::Reference< uno::XInterface >(), 0 ); if (pEntry->getName() != aName ) |