summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/lz4.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/lz4.c b/lib/lz4.c
index 646a13c..d250509 100644
--- a/lib/lz4.c
+++ b/lib/lz4.c
@@ -171,6 +171,7 @@ static U32 LZ4_read32(const void* memPtr) { return *(const U32*) memPtr; }
static size_t LZ4_read_ARCH(const void* memPtr) { return *(const size_t*) memPtr; }
static void LZ4_write16(void* memPtr, U16 value) { *(U16*)memPtr = value; }
+static void LZ4_write32(void* memPtr, U32 value) { *(U32*)memPtr = value; }
#elif defined(LZ4_FORCE_MEMORY_ACCESS) && (LZ4_FORCE_MEMORY_ACCESS==1)
@@ -183,6 +184,7 @@ static U32 LZ4_read32(const void* ptr) { return ((const unalign*)ptr)->u32; }
static size_t LZ4_read_ARCH(const void* ptr) { return ((const unalign*)ptr)->uArch; }
static void LZ4_write16(void* memPtr, U16 value) { ((unalign*)memPtr)->u16 = value; }
+static void LZ4_write32(void* memPtr, U32 value) { ((unalign*)memPtr)->u32 = value; }
#else
@@ -206,6 +208,11 @@ static void LZ4_write16(void* memPtr, U16 value)
memcpy(memPtr, &value, sizeof(value));
}
+static void LZ4_write32(void* memPtr, U32 value)
+{
+ memcpy(memPtr, &value, sizeof(value));
+}
+
#endif /* LZ4_FORCE_MEMORY_ACCESS */
@@ -605,8 +612,8 @@ _next_match:
if (matchCode >= ML_MASK) {
*token += ML_MASK;
matchCode -= ML_MASK;
- *(U32*)op = 0xFFFFFFFF;
- while (matchCode >= 4*255) op+=4, *(U32*)op=0xFFFFFFFF, matchCode -= 4*255;
+ LZ4_write32(op, 0xFFFFFFFF);
+ while (matchCode >= 4*255) op+=4, LZ4_write32(op, 0xFFFFFFFF), matchCode -= 4*255;
op += matchCode / 255;
*op++ = (BYTE)(matchCode % 255);
} else
@@ -1199,8 +1206,8 @@ FORCE_INLINE int LZ4_decompress_generic(
if (length == ML_MASK) {
unsigned s;
do {
- if ((endOnInput) && (ip > iend-LASTLITERALS)) goto _output_error;
s = *ip++;
+ if ((endOnInput) && (ip > iend-LASTLITERALS)) goto _output_error;
length += s;
} while (s==255);
if ((safeDecode) && unlikely((size_t)(op+length)<(size_t)op)) goto _output_error; /* overflow detection */