summaryrefslogtreecommitdiff
path: root/bridges
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-12-15 16:52:19 +0100
committerStephan Bergmann <sbergman@redhat.com>2015-12-15 16:52:19 +0100
commit27f5679c84602713e74c947d88e72cfafc02fbc8 (patch)
tree3bb940b1b8af84c9dca3ad78fc99a825e9706716 /bridges
parent3bb7557d541328194eae928fda32b73650f13360 (diff)
tdf#95903: Fix return value handling in msvc_win32_x86-64 bridge
...where a return value was double-deleted if it was "complex" (i.e., generated by callee into caller-provided memory) but not related to UNO interface types (so doesn't need any mapping, like sequence<css.beans.Property> returned by css.beans.XPropertySetInfo.getProperties). Change-Id: I4cfc16ba63022686afd016ef5b64419e8dee53a4
Diffstat (limited to 'bridges')
-rw-r--r--bridges/source/cpp_uno/msvc_win32_x86-64/uno2cpp.cxx44
1 files changed, 30 insertions, 14 deletions
diff --git a/bridges/source/cpp_uno/msvc_win32_x86-64/uno2cpp.cxx b/bridges/source/cpp_uno/msvc_win32_x86-64/uno2cpp.cxx
index 35ca9ebd22e6..ada36234eefd 100644
--- a/bridges/source/cpp_uno/msvc_win32_x86-64/uno2cpp.cxx
+++ b/bridges/source/cpp_uno/msvc_win32_x86-64/uno2cpp.cxx
@@ -17,6 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sal/config.h>
+
+#include <cassert>
#include <malloc.h>
@@ -77,16 +80,21 @@ static bool cpp_call(
void * pAdjustedThisPtr = (void **)( pThis->getCppI() ) + aVtableSlot.offset;
aCppParams[nCppParamIndex++].p = pAdjustedThisPtr;
- bool bSimpleReturn = true;
- if ( pReturnTD )
- {
- if ( !bridges::cpp_uno::shared::isSimpleType( pReturnTD ) )
+ enum class ReturnKind { Void, Simple, Complex, ComplexConvert };
+ ReturnKind retKind;
+ if (pUnoReturn == nullptr) {
+ retKind = ReturnKind::Void;
+ } else {
+ assert(pReturnTD != nullptr);
+ if (bridges::cpp_uno::shared::isSimpleType(pReturnTD)) {
+ retKind = ReturnKind::Simple;
+ } else if (bridges::cpp_uno::shared::relatesToInterfaceType(pReturnTD))
{
- // Complex return via ptr
- bSimpleReturn = false;
- aCppParams[nCppParamIndex++].p =
- bridges::cpp_uno::shared::relatesToInterfaceType( pReturnTD )?
- alloca( pReturnTD->nSize ) : pUnoReturn;
+ retKind = ReturnKind::ComplexConvert;
+ aCppParams[nCppParamIndex++].p = alloca(pReturnTD->nSize);
+ } else {
+ retKind = ReturnKind::Complex;
+ aCppParams[nCppParamIndex++].p = pUnoReturn;
}
}
@@ -267,16 +275,24 @@ static bool cpp_call(
}
// Return value
- if ( !bSimpleReturn )
- {
+ switch (retKind) {
+ case ReturnKind::Void:
+ break;
+ case ReturnKind::Simple:
+ *(sal_Int64*)pUnoReturn = uRetVal.i;
+ break;
+ case ReturnKind::Complex:
+ assert(uRetVal.p == pUnoReturn);
+ break;
+ case ReturnKind::ComplexConvert:
+ assert(uRetVal.p == aCppParams[1].p);
::uno_copyAndConvertData(
pUnoReturn, uRetVal.p, pReturnTD,
pThis->getBridge()->getCpp2Uno() );
::uno_destructData(
- aCppParams[1].p, pReturnTD, cpp_release );
+ uRetVal.p, pReturnTD, cpp_release );
+ break;
}
- else if ( pUnoReturn )
- *(sal_Int64*)pUnoReturn = uRetVal.i;
if ( pReturnTD )
TYPELIB_DANGER_RELEASE( pReturnTD );