summaryrefslogtreecommitdiff
path: root/src/net/ea
diff options
context:
space:
mode:
authorBernd Wachter <bwachter-tmw@lart.info>2009-11-14 02:22:06 +0100
committerJared Adams <jaxad0127@gmail.com>2009-11-13 19:18:03 -0700
commit4b1aeab2af7467046cd9e411da899ce770bcd780 (patch)
treeed1bc577edf259ea67f782ff97fe70dfde17e7d8 /src/net/ea
parent546e7e29628454e18aa8af27882545b302550a03 (diff)
downloadmana-4b1aeab2af7467046cd9e411da899ce770bcd780.tar.gz
mana-4b1aeab2af7467046cd9e411da899ce770bcd780.tar.bz2
mana-4b1aeab2af7467046cd9e411da899ce770bcd780.tar.xz
mana-4b1aeab2af7467046cd9e411da899ce770bcd780.zip
Copy ints by memcpy to avoid segfaults on sparc
Diffstat (limited to 'src/net/ea')
-rw-r--r--src/net/ea/messagein.cpp8
-rw-r--r--src/net/ea/messageout.cpp6
2 files changed, 10 insertions, 4 deletions
diff --git a/src/net/ea/messagein.cpp b/src/net/ea/messagein.cpp
index 0b1ab70a..1cca786a 100644
--- a/src/net/ea/messagein.cpp
+++ b/src/net/ea/messagein.cpp
@@ -43,7 +43,9 @@ int MessageIn::readInt16()
if (mPos + 2 <= mLength)
{
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- value = SDL_Swap16(*(Sint16*)(mData + mPos));
+ Sint16 swap;
+ memcpy(&swap, mData + mPos, sizeof(Sint16));
+ value = SDL_Swap16(swap);
#else
value = (*(Sint16*)(mData + mPos));
#endif
@@ -58,7 +60,9 @@ int MessageIn::readInt32()
if (mPos + 4 <= mLength)
{
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- value = SDL_Swap32(*(Sint32*)(mData + mPos));
+ Sint32 swap;
+ memcpy(&swap, mData + mPos, sizeof(Sint32));
+ value = SDL_Swap32(swap);
#else
value = (*(Sint32*)(mData + mPos));
#endif
diff --git a/src/net/ea/messageout.cpp b/src/net/ea/messageout.cpp
index f75dcf7e..9493ee80 100644
--- a/src/net/ea/messageout.cpp
+++ b/src/net/ea/messageout.cpp
@@ -48,7 +48,8 @@ void MessageOut::writeInt16(Sint16 value)
{
expand(2);
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- (*(Sint16 *)(mData + mPos)) = SDL_Swap16(value);
+ Sint16 swap=SDL_Swap16(value);
+ memcpy(mData + mPos, &swap, sizeof(Sint16));
#else
(*(Sint16 *)(mData + mPos)) = value;
#endif
@@ -59,7 +60,8 @@ void MessageOut::writeInt32(Sint32 value)
{
expand(4);
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- (*(Sint32 *)(mData + mPos)) = SDL_Swap32(value);
+ Sint32 swap=SDL_Swap32(value);
+ memcpy(mData + mPos, &swap, sizeof(Sint32));
#else
(*(Sint32 *)(mData + mPos)) = value;
#endif