This is an automated email from the ASF dual-hosted git repository.

leginee pushed a commit to branch win10-msvc-trunk
in repository https://gitbox.apache.org/repos/asf/openoffice.git

commit 9e97a9720d9e9d98c2cd01474bd9afed4ea1e1f5
Author: Peter Kovacs <[email protected]>
AuthorDate: Sun Aug 23 00:02:32 2026 +0200

    rsc: the name table stores an RscTop*, so yylval must be pointer-width
    
    KEY_STRUCT::yylval was a long -- 32 bit on Windows x64 -- and
    RscNameTable::Put casts a class pointer straight into it:
    
        Put( Atom nName, sal_uInt32 nTyp, RscTop * pClass )
        { return Put( nName, nTyp, (long)pClass ); }
    
    Every RscTop* in the resource compiler's name table was therefore truncated
    on store, and the lexer cast the truncated value back on read:
    
        case CLASSNAME:
            pTokenVal->pClass = (RscTop *)aKey.yylval;
    
    which the yacc grammar hands to DoClassHeader as $$.pClass.  rsc2 then took
    an access violation loading a vtable through it:
    
        rsc2!DoClassHeader+0x2b2  mov rax,qword ptr [rcx]
        rcx = 00000000`1dab5b40   (live pointers carried a 00000234 prefix)
    
    This was not one module's problem: rsc2 crashed on every .src file,
    including a 2 KB one, so resource compilation had never worked on x64 at
    all.  sccomp merely happened to be the first [ build srs ] the build
    reached.
    
    Widening yylval to sal_IntPtr then made 19 call sites ambiguous -- (long)0
    had been an exact match and now ties with the null-pointer conversion to the
    RscTop* overload (C2668) -- so those casts move to (sal_IntPtr) too.  All 19
    were verified to be Put arguments before converting.
    
    The generated .srs for sccomp/source/solver is now byte-identical to the
    x86 build's:  fd037405f783a4bccd80ea66fe89e6df
    
    Co-Authored-By: Claude Opus 5 <[email protected]>
    Claude-Session: https://claude.ai/code/session_01VrM7EMKgiuyVcCUe9nSbZR
---
 main/rsc/inc/rsckey.hxx            |  6 +++---
 main/rsc/source/parser/rscibas.cxx |  2 +-
 main/rsc/source/parser/rscinit.cxx | 36 ++++++++++++++++++------------------
 main/rsc/source/parser/rsckey.cxx  | 12 ++++++------
 main/rsc/source/parser/rsclex.cxx  |  4 ++--
 5 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/main/rsc/inc/rsckey.hxx b/main/rsc/inc/rsckey.hxx
index 27a83a4648..acad74df99 100644
--- a/main/rsc/inc/rsckey.hxx
+++ b/main/rsc/inc/rsckey.hxx
@@ -31,7 +31,7 @@ class RscTop;
 typedef struct {
     Atom          nName;
     sal_uInt32          nTyp;
-    long            yylval;
+    sal_IntPtr      yylval;
 } KEY_STRUCT;
 
 class RscNameTable {
@@ -42,9 +42,9 @@ public:
             RscNameTable();
             ~RscNameTable();
     void    SetSort( sal_Bool bSorted = sal_True );
-    Atom  Put( Atom nName, sal_uInt32 nTyp, long nValue );
+    Atom  Put( Atom nName, sal_uInt32 nTyp, sal_IntPtr nValue );
     Atom  Put( Atom nName, sal_uInt32 nTyp );
-    Atom  Put( const char * pName, sal_uInt32 nTyp, long nValue );
+    Atom  Put( const char * pName, sal_uInt32 nTyp, sal_IntPtr nValue );
     Atom  Put( const char * pName, sal_uInt32 nTyp );
     Atom  Put( Atom nName, sal_uInt32 nTyp, RscTop * pClass );
     Atom  Put( const char * pName, sal_uInt32 nTyp, RscTop * pClass );
diff --git a/main/rsc/source/parser/rscibas.cxx 
b/main/rsc/source/parser/rscibas.cxx
index d68c7c6637..be092bff5b 100644
--- a/main/rsc/source/parser/rscibas.cxx
+++ b/main/rsc/source/parser/rscibas.cxx
@@ -86,7 +86,7 @@ sal_uInt32 GetLangId( const ByteString& aLang )
 
 void RscLangEnum::Init( RscNameTable& rNames )
 {
-    SetConstant( rNames.Put( "SYSTEM", CONSTNAME, (long)LANGUAGE_SYSTEM ), 
LANGUAGE_SYSTEM );
+    SetConstant( rNames.Put( "SYSTEM", CONSTNAME, (sal_IntPtr)LANGUAGE_SYSTEM 
), LANGUAGE_SYSTEM );
     SetConstant( rNames.Put( "DONTKNOW", CONSTNAME, LANGUAGE_DONTKNOW ), 
LANGUAGE_DONTKNOW );
 
     sal_Int32 nIndex = 0;
diff --git a/main/rsc/source/parser/rscinit.cxx 
b/main/rsc/source/parser/rscinit.cxx
index 5370999d73..c66fd7da43 100644
--- a/main/rsc/source/parser/rscinit.cxx
+++ b/main/rsc/source/parser/rscinit.cxx
@@ -193,18 +193,18 @@ void RscTypCont::Init()
        aNmTb.SetSort( sal_False );
 {
        /********** C O M P I L E R   T Y P E N ******************************/
-       aNmTb.Put( "LINE",               LINE,           (long)0 );
-       aNmTb.Put( "NOT",                NOT,            (long)0 );
-       aNmTb.Put( "DEFINE",             DEFINE,         (long)0 );
-       aNmTb.Put( "INCLUDE",            INCLUDE,        (long)0 );
-       aNmTb.Put( "DEFAULT",            DEFAULT,        (long)0  );
-       aNmTb.Put( "class",              CLASS,          (long)0  );
-       aNmTb.Put( "extendable",         EXTENDABLE,     (long)0  );
-       aNmTb.Put( "writeifset",         WRITEIFSET,     (long)0  );
+       aNmTb.Put( "LINE",               LINE,           (sal_IntPtr)0 );
+       aNmTb.Put( "NOT",                NOT,            (sal_IntPtr)0 );
+       aNmTb.Put( "DEFINE",             DEFINE,         (sal_IntPtr)0 );
+       aNmTb.Put( "INCLUDE",            INCLUDE,        (sal_IntPtr)0 );
+       aNmTb.Put( "DEFAULT",            DEFAULT,        (sal_IntPtr)0  );
+       aNmTb.Put( "class",              CLASS,          (sal_IntPtr)0  );
+       aNmTb.Put( "extendable",         EXTENDABLE,     (sal_IntPtr)0  );
+       aNmTb.Put( "writeifset",         WRITEIFSET,     (sal_IntPtr)0  );
 
 /* Werte fuer Aufzaehlungstypen */
-       aNmTb.Put( "TRUE",               BOOLEAN,        (long)sal_True  );
-       aNmTb.Put( "FALSE",              BOOLEAN,        (long)sal_False );
+       aNmTb.Put( "TRUE",               BOOLEAN,        (sal_IntPtr)sal_True  
);
+       aNmTb.Put( "FALSE",              BOOLEAN,        (sal_IntPtr)sal_False 
);
 
        #if 0
 /* Vordefinierte HilfeId's */
@@ -212,14 +212,14 @@ void RscTypCont::Init()
        aNmTb.Put( "HELP_HELPONHELP",    NUMBER,     OOO_HELP_HELPONHELP );
        #endif
 
-       aNmTb.Put( "XSCALE",             XSCALE ,        (long)0     );
-       aNmTb.Put( "YSCALE",             YSCALE ,        (long)0     );
-       aNmTb.Put( "RGB",                RGB    ,        (long)0     );
-       aNmTb.Put( "POSSIZE",            GEOMETRY,       (long)0     );
-       aNmTb.Put( "POS",                POSITION,       (long)0     );
-       aNmTb.Put( "SIZE",               DIMENSION,      (long)0     );
-       aNmTb.Put( "ZoomInOutputSize",   INZOOMOUTPUTSIZE,(long)0    );
-       aNmTb.Put( "FloatingPos",        FLOATINGPOS,    (long)0     );
+       aNmTb.Put( "XSCALE",             XSCALE ,        (sal_IntPtr)0     );
+       aNmTb.Put( "YSCALE",             YSCALE ,        (sal_IntPtr)0     );
+       aNmTb.Put( "RGB",                RGB    ,        (sal_IntPtr)0     );
+       aNmTb.Put( "POSSIZE",            GEOMETRY,       (sal_IntPtr)0     );
+       aNmTb.Put( "POS",                POSITION,       (sal_IntPtr)0     );
+       aNmTb.Put( "SIZE",               DIMENSION,      (sal_IntPtr)0     );
+       aNmTb.Put( "ZoomInOutputSize",   INZOOMOUTPUTSIZE,(sal_IntPtr)0    );
+       aNmTb.Put( "FloatingPos",        FLOATINGPOS,    (sal_IntPtr)0     );
 }
        /********** B A S I S   T Y P E N ************************************/
 {
diff --git a/main/rsc/source/parser/rsckey.cxx 
b/main/rsc/source/parser/rsckey.cxx
index 720b2260f9..0eada89d92 100644
--- a/main/rsc/source/parser/rsckey.cxx
+++ b/main/rsc/source/parser/rsckey.cxx
@@ -121,7 +121,7 @@ void RscNameTable::SetSort( sal_Bool bSorted ){
 |*    Letzte Aenderung  MM 28.02.91
 |*
 *************************************************************************/
-Atom RscNameTable::Put( Atom nName, sal_uInt32 nTyp, long nValue ){
+Atom RscNameTable::Put( Atom nName, sal_uInt32 nTyp, sal_IntPtr nValue ){
     if( pTable )
         pTable = (KEY_STRUCT *)
                  rtl_reallocateMemory( (void *)pTable,
@@ -139,14 +139,14 @@ Atom RscNameTable::Put( Atom nName, sal_uInt32 nTyp, long 
nValue ){
     return( nName );
 };
 
-Atom RscNameTable::Put( const char * pName, sal_uInt32 nTyp, long nValue )
+Atom RscNameTable::Put( const char * pName, sal_uInt32 nTyp, sal_IntPtr nValue 
)
 {
     return( Put( pHS->getID( pName ), nTyp, nValue ) );
 };
 
 Atom RscNameTable::Put( Atom nName, sal_uInt32 nTyp )
 {
-    return( Put( nName, nTyp, (long)nName ) );
+    return( Put( nName, nTyp, (sal_IntPtr)nName ) );
 };
 
 Atom RscNameTable::Put( const char * pName, sal_uInt32 nTyp )
@@ -154,17 +154,17 @@ Atom RscNameTable::Put( const char * pName, sal_uInt32 
nTyp )
     Atom  nId;
 
     nId = pHS->getID( pName );
-    return( Put( nId, nTyp, (long)nId ) );
+    return( Put( nId, nTyp, (sal_IntPtr)nId ) );
 };
 
 Atom RscNameTable::Put( Atom nName, sal_uInt32 nTyp, RscTop * pClass )
 {
-    return( Put( nName, nTyp, (long)pClass ) );
+    return( Put( nName, nTyp, (sal_IntPtr)pClass ) );
 };
 
 Atom RscNameTable::Put( const char * pName, sal_uInt32 nTyp, RscTop * pClass )
 {
-    return( Put( pHS->getID( pName ), nTyp, (long)pClass ) );
+    return( Put( pHS->getID( pName ), nTyp, (sal_IntPtr)pClass ) );
 };
 
 /*************************************************************************
diff --git a/main/rsc/source/parser/rsclex.cxx 
b/main/rsc/source/parser/rsclex.cxx
index ed6727fdf1..c620097efa 100644
--- a/main/rsc/source/parser/rsclex.cxx
+++ b/main/rsc/source/parser/rsclex.cxx
@@ -233,7 +233,7 @@ int MakeToken( YYSTYPE * pTokenVal ){
                         break;
                     case CONSTNAME:
                         pTokenVal->constname.hashid = aKey.nName;
-                        pTokenVal->constname.nValue = aKey.yylval;
+                        pTokenVal->constname.nValue = (sal_Int32)aKey.yylval;
                         break;
                     case BOOLEAN:
                         pTokenVal->svbool = (sal_Bool)aKey.yylval;
@@ -241,7 +241,7 @@ int MakeToken( YYSTYPE * pTokenVal ){
                     case INCLUDE:
                         bLastInclude = sal_True;
                     default:
-                        pTokenVal->value = aKey.yylval;
+                        pTokenVal->value = (sal_Int32)aKey.yylval;
                 };
 
                 return( aKey.nTyp );

Reply via email to