From c510683d2a64e75a667134ef0b63e9638c474c28 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 2 Jan 2014 17:33:18 +0100 Subject: Fixed unaligned memory access in FastNBT. This should fix #420. --- src/StringUtils.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/StringUtils.cpp') diff --git a/src/StringUtils.cpp b/src/StringUtils.cpp index f7aeeed26..5c6b99d88 100644 --- a/src/StringUtils.cpp +++ b/src/StringUtils.cpp @@ -764,3 +764,33 @@ AString Base64Decode(const AString & a_Base64String) + +short GetBEShort(const char * a_Mem) +{ + return (((short)a_Mem[0]) << 8) | a_Mem[1]; +} + + + + + +int GetBEInt(const char * a_Mem) +{ + return (((int)a_Mem[0]) << 24) | (((int)a_Mem[1]) << 16) | (((int)a_Mem[2]) << 8) | a_Mem[3]; +} + + + + + +void SetBEInt(char * a_Mem, Int32 a_Value) +{ + a_Mem[0] = a_Value >> 24; + a_Mem[1] = (a_Value >> 16) & 0xff; + a_Mem[2] = (a_Value >> 8) & 0xff; + a_Mem[3] = a_Value & 0xff; +} + + + + -- cgit v1.2.3