You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by pe...@apache.org on 2026/07/27 06:50:36 UTC
(openoffice) 16/20: bridges/msvc_win64: pass simple argument values, not the temp's address
This is an automated email from the ASF dual-hosted git repository.
leginee pushed a commit to branch bazel-migration
in repository https://gitbox.apache.org/repos/asf/openoffice.git
commit c671a9c6a1eeb5154ea2990db985535761436919
Author: Peter Kovacs <pe...@apache.org>
AuthorDate: Mon Jul 27 07:06:55 2026 +0200
bridges/msvc_win64: pass simple argument values, not the temp's address
uno2cpp.cxx converts each simple by-value argument into an 8-byte alloca
temp and stores the pointer in pCppArgs[nPos]:
uno_copyAndConvertData( pCppArgs[nPos] = alloca( 8 ), ... );
Copying the value into the outgoing slot therefore has to dereference that
pointer. The marshalling switch used &pCppArgs[nPos] instead, which reads
the pCppArgs array slot itself, i.e. the temp's address -- so every HYPER,
LONG, ENUM, SHORT, CHAR, BOOLEAN, BYTE, FLOAT and DOUBLE parameter reached
the callee as a stack address (or its low 16/32 bits) rather than a value.
The same expression is correct in the complex/ref branch, where the pointer
IS the argument; written there as (sal_uInt64)pCppArgs[nPos] to make the
difference between the two branches obvious.
This only affects calls that cross between the uno and cpp environments, so
a pure-C++ session never trips it; it surfaces via pyuno and the invocation
adapters.
Co-Authored-By: Claude Opus 5 <no...@anthropic.com>
---
.../source/cpp_uno/msvc_win64_x86-64/uno2cpp.cxx | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/main/bridges/source/cpp_uno/msvc_win64_x86-64/uno2cpp.cxx b/main/bridges/source/cpp_uno/msvc_win64_x86-64/uno2cpp.cxx
index 2f8e80ca4d..b9e43adb45 100644
--- a/main/bridges/source/cpp_uno/msvc_win64_x86-64/uno2cpp.cxx
+++ b/main/bridges/source/cpp_uno/msvc_win64_x86-64/uno2cpp.cxx
@@ -105,29 +105,34 @@ static void cpp_call(
uno_copyAndConvertData( pCppArgs[nPos] = alloca( 8 ), pUnoArgs[nPos], pParamTypeDescr,
pThis->getBridge()->getUno2Cpp() );
+ // pCppArgs[nPos] is the alloca(8) temp above, i.e. a POINTER to the
+ // converted value -- the value is *pCppArgs[nPos]. Using
+ // &pCppArgs[nPos] would read the array slot instead, passing the
+ // temp's address as the argument. (That form is correct only in the
+ // complex/ref branch below, where the pointer IS the argument.)
switch (pParamTypeDescr->eTypeClass)
{
case typelib_TypeClass_HYPER:
case typelib_TypeClass_UNSIGNED_HYPER:
- *pStack++ = *(sal_uInt64*)&pCppArgs[nPos];
+ *pStack++ = *(sal_uInt64*)pCppArgs[nPos];
break;
case typelib_TypeClass_LONG:
case typelib_TypeClass_UNSIGNED_LONG:
case typelib_TypeClass_ENUM:
- *pStack++ = *(sal_uInt32*)&pCppArgs[nPos];
+ *pStack++ = *(sal_uInt32*)pCppArgs[nPos];
break;
case typelib_TypeClass_SHORT:
case typelib_TypeClass_UNSIGNED_SHORT:
case typelib_TypeClass_CHAR:
- *pStack++ = *(sal_uInt16*)&pCppArgs[nPos];
+ *pStack++ = *(sal_uInt16*)pCppArgs[nPos];
break;
case typelib_TypeClass_BOOLEAN:
case typelib_TypeClass_BYTE:
- *pStack++ = *(sal_uInt8*)&pCppArgs[nPos];
+ *pStack++ = *(sal_uInt8*)pCppArgs[nPos];
break;
case typelib_TypeClass_FLOAT:
case typelib_TypeClass_DOUBLE:
- *pStack++ = *(sal_uInt64*)&pCppArgs[nPos]; // verbatim!
+ *pStack++ = *(sal_uInt64*)pCppArgs[nPos]; // verbatim!
break;
default:
break;
@@ -164,7 +169,8 @@ static void cpp_call(
// no longer needed
TYPELIB_DANGER_RELEASE( pParamTypeDescr );
}
- *pStack++ = *(sal_uInt64*)&pCppArgs[nPos];
+ // here the POINTER is the argument (complex value passed by ref)
+ *pStack++ = (sal_uInt64)pCppArgs[nPos];
}
}