[Libreoffice-commits] core.git: bridges/source

Stephan Bergmann sbergman at redhat.com
Tue Dec 9 07:16:46 PST 2014


 bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx |   45 ++++++++++++++------
 1 file changed, 33 insertions(+), 12 deletions(-)

New commits:
commit 8ad2b6f9d8169b46a71b82198ff1f73482a602e8
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Dec 9 16:10:17 2014 +0100

    Fix base+offset pointer calculations when synthesizing exception data
    
    ...but the code does not yet work:  Care must be taken to allocate the various
    data structures close enough together so that the offset calculations at the
    four places now marked with
    
        assert(...); //TODO
    
    actually succeed.
    
    Change-Id: I1fedf7d2d3cdde5035842b4ad5eca9ad9ccf2d44

diff --git a/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx b/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx
index 70a6637..5ea44f2 100644
--- a/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx
+++ b/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx
@@ -466,9 +466,20 @@ struct ExceptionType
             // As _n0 is always initialized to zero, that means the
             // hasvirtbase flag (see the ONTL catchabletype struct) is
             // off, and thus the copyctor is of the ctor_ptr kind.
-            _pTypeInfo = (sal_uInt32) ((sal_uInt64) mscx_getRTTI( pTD->pTypeName ) - pCodeBase);
+            type_info * ti = mscx_getRTTI(pTD->pTypeName);
+            assert(
+                pCodeBase <= reinterpret_cast<sal_uInt64>(ti)
+                && reinterpret_cast<sal_uInt64>(ti) - pCodeBase < 0x100000000);
+                //TODO
+            _pTypeInfo = static_cast<sal_uInt32>(
+                reinterpret_cast<sal_uInt64>(ti) - pCodeBase);
             GenerateConstructorTrampoline( pCode, pTD );
-            _pCopyCtor = (sal_uInt32) ((sal_uInt64) pCode - pCodeBase);
+            assert(
+                pCodeBase <= reinterpret_cast<sal_uInt64>(pCode)
+                && (reinterpret_cast<sal_uInt64>(pCode) - pCodeBase
+                    < 0x100000000)); //TODO
+            _pCopyCtor = static_cast<sal_uInt32>(
+                reinterpret_cast<sal_uInt64>(pCode) - pCodeBase);
         }
     inline ~ExceptionType() throw ()
         {
@@ -533,7 +544,8 @@ RaiseInfo::RaiseInfo( typelib_TypeDescription * pTD )throw ()
 
     unsigned char * pCode = _code = (unsigned char *)::rtl_allocateMemory( codeSize );
 
-    _codeBase = (sal_uInt64)pCode & ~(ExceptionInfos::allocationGranularity-1);
+    _codeBase = reinterpret_cast<sal_uInt64>(pCode)
+        & ~static_cast<sal_uInt64>(ExceptionInfos::allocationGranularity - 1);
 
     DWORD old_protect;
 #if OSL_DEBUG_LEVEL > 0
@@ -549,19 +561,28 @@ RaiseInfo::RaiseInfo( typelib_TypeDescription * pTD )throw ()
     pCode += codeSnippetSize;
 
     // Info count accompanied by type info ptrs: type, base type, base base type, ...
-    _types = (sal_Int32)((sal_uInt64)::rtl_allocateMemory( 4 + 4* nLen) - _codeBase);
-    *(sal_Int32 *)_types = nLen;
-
-    ExceptionType ** ppTypes = (ExceptionType **)((sal_Int32 *)_types + 1);
-
-    int nPos = 0;
+    DWORD * types = static_cast<DWORD *>(rtl_allocateMemory(4 + 4 * nLen));
+    assert(
+        _codeBase <= reinterpret_cast<sal_uInt64>(types)
+        && reinterpret_cast<sal_uInt64>(types) - _codeBase < 0x100000000);
+        //TODO
+    _types = static_cast<sal_Int32>(
+        reinterpret_cast<sal_uInt64>(types) - _codeBase);
+    types[0] = nLen;
+
+    int nPos = 1;
     for ( pCompTD = (typelib_CompoundTypeDescription*)pTD;
           pCompTD; pCompTD = pCompTD->pBaseTypeDescription )
     {
-        ppTypes[nPos++] =
-            new ExceptionType( pCode, _codeBase,
-                               (typelib_TypeDescription *)pCompTD );
+        ExceptionType * et = new ExceptionType(
+            pCode, _codeBase, (typelib_TypeDescription *)pCompTD);
         pCode += codeSnippetSize;
+        assert(
+            _codeBase <= reinterpret_cast<sal_uInt64>(et)
+            && reinterpret_cast<sal_uInt64>(et) - _codeBase < 0x100000000);
+            //TODO
+        types[nPos++]
+            = static_cast<DWORD>(reinterpret_cast<sal_uInt64>(et) - _codeBase);
     }
 }
 


More information about the Libreoffice-commits mailing list