mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 15:21:51 +00:00
- Do not crash when reading ATAG chunks on processors that don't like unaligned accesses.
SVN r3991 (trunk)
This commit is contained in:
parent
e8731c7571
commit
2022d64ee2
1 changed files with 22 additions and 15 deletions
|
@ -173,6 +173,27 @@ TArray<FString>
|
|||
#define STRINGBUILDER_START(Builder) if (Builder.IsNotEmpty() || ACS_StringBuilderStack.Size()) { ACS_StringBuilderStack.Push(Builder); Builder = ""; }
|
||||
#define STRINGBUILDER_FINISH(Builder) if (!ACS_StringBuilderStack.Pop(Builder)) { Builder = ""; }
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
// uallong
|
||||
//
|
||||
// Read a possibly unaligned four-byte little endian integer from memory.
|
||||
//
|
||||
//============================================================================
|
||||
|
||||
#if defined(_M_IX86) || defined(_M_X64) || defined(__i386__)
|
||||
inline int uallong(const int &foo)
|
||||
{
|
||||
return foo;
|
||||
}
|
||||
#else
|
||||
inline int uallong(const int &foo)
|
||||
{
|
||||
const unsigned char *bar = (const unsigned char *)&foo;
|
||||
return bar[0] | (bar[1] << 8) | (bar[2] << 16) | (bar[3] << 24);
|
||||
}
|
||||
#endif
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
// ScriptPresentation
|
||||
|
@ -1259,7 +1280,7 @@ FBehavior::FBehavior (int lumpnum, FileReader * fr, int len)
|
|||
// First byte is version, it should be 0
|
||||
if(*chunkData++ == 0)
|
||||
{
|
||||
int arraynum = MapVarStore[LittleLong(*(const DWORD*)(chunkData))];
|
||||
int arraynum = MapVarStore[uallong(*(const int*)(chunkData))];
|
||||
chunkData += 4;
|
||||
if ((unsigned)arraynum < (unsigned)NumArrays)
|
||||
{
|
||||
|
@ -4010,20 +4031,6 @@ inline int getshort (int *&pc)
|
|||
return res;
|
||||
}
|
||||
|
||||
// Read a possibly unaligned four-byte little endian integer.
|
||||
#if defined(_M_IX86) || defined(_M_X64) || defined(__i386__)
|
||||
inline int uallong(int &foo)
|
||||
{
|
||||
return foo;
|
||||
}
|
||||
#else
|
||||
inline int uallong(int &foo)
|
||||
{
|
||||
unsigned char *bar = (unsigned char *)&foo;
|
||||
return bar[0] | (bar[1] << 8) | (bar[2] << 16) | (bar[3] << 24);
|
||||
}
|
||||
#endif
|
||||
|
||||
int DLevelScript::RunScript ()
|
||||
{
|
||||
DACSThinker *controller = DACSThinker::ActiveThinker;
|
||||
|
|
Loading…
Reference in a new issue