Skip to content

Commit 2b1bcee

Browse files
authored
fix: Wrong usage of sizeof(this) in BitFlags::xfer(), W3DMPO::glueEnforcer() (#1947)
1 parent 2a1593e commit 2b1bcee

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

Core/Libraries/Source/WWVegas/WWLib/always.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ private: \
144144
return The##ARGCLASS##Pool; \
145145
} \
146146
protected: \
147-
virtual int glueEnforcer() const { return sizeof(this); } \
147+
virtual void glueEnforcer() const { } \
148148
public: \
149149
inline void* operator new(size_t s) { return allocateFromW3DMemPool(getClassMemoryPool(), s); } \
150150
inline void operator delete(void *p) { freeFromW3DMemPool(getClassMemoryPool(), p); } \
@@ -162,7 +162,7 @@ class W3DMPO
162162
}
163163
protected:
164164
// we never call this; it is present to cause compile errors in descendent classes
165-
virtual int glueEnforcer() const = 0;
165+
virtual void glueEnforcer() const = 0;
166166
public:
167167
virtual ~W3DMPO() { /* nothing */ }
168168
};

Generals/Code/GameEngine/Include/Common/BitFlagsIO.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,11 @@ void BitFlags<NUMBITS>::xfer(Xfer* xfer)
214214
{
215215

216216
// just call the xfer implementation on the data values
217+
#if RETAIL_COMPATIBLE_CRC
217218
xfer->xferUser( this, sizeof( this ) );
219+
#else
220+
xfer->xferUser( this, sizeof( *this ) );
221+
#endif
218222

219223
}
220224
else

GeneralsMD/Code/GameEngine/Include/Common/BitFlagsIO.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,11 @@ void BitFlags<NUMBITS>::xfer(Xfer* xfer)
214214
{
215215

216216
// just call the xfer implementation on the data values
217+
#if RETAIL_COMPATIBLE_CRC
217218
xfer->xferUser( this, sizeof( this ) );
219+
#else
220+
xfer->xferUser( this, sizeof( *this ) );
221+
#endif
218222

219223
}
220224
else

0 commit comments

Comments
 (0)