summaryrefslogtreecommitdiffstats
path: root/lib/lz4.c
diff options
context:
space:
mode:
authorYann Collet <cyan@fb.com>2016-11-17 21:02:06 (GMT)
committerYann Collet <cyan@fb.com>2016-11-17 21:02:06 (GMT)
commit1abecbc33c8ec5b84d2623dcbe73136aeb99db37 (patch)
tree398361394772160cd31cbc2b496d4814484fcb10 /lib/lz4.c
parent7fde7438d39f8452f89e3fee5ba4a16c502dffb0 (diff)
downloadlz4-1abecbc33c8ec5b84d2623dcbe73136aeb99db37.zip
lz4-1abecbc33c8ec5b84d2623dcbe73136aeb99db37.tar.gz
lz4-1abecbc33c8ec5b84d2623dcbe73136aeb99db37.tar.bz2
fix 32-bits mode.
Large File support for Mac OS-X in 32-bits mode Fixed potential undefined behavior Changed makefile for 32-bits mode
Diffstat (limited to 'lib/lz4.c')
-rw-r--r--lib/lz4.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/lz4.c b/lib/lz4.c
index 89e3a0f..bdbc73f 100644
--- a/lib/lz4.c
+++ b/lib/lz4.c
@@ -141,12 +141,14 @@
typedef uint32_t U32;
typedef int32_t S32;
typedef uint64_t U64;
+ typedef uintptr_t uptrval;
#else
typedef unsigned char BYTE;
typedef unsigned short U16;
typedef unsigned int U32;
typedef signed int S32;
typedef unsigned long long U64;
+ typedef size_t uptrval; /* generally true, except OpenVMS-64 */
#endif
@@ -1139,8 +1141,8 @@ FORCE_INLINE int LZ4_decompress_generic(
s = *ip++;
length += s;
} while ( likely(endOnInput ? ip<iend-RUN_MASK : 1) & (s==255) );
- if ((safeDecode) && unlikely((size_t)(op+length)<(size_t)(op))) goto _output_error; /* overflow detection */
- if ((safeDecode) && unlikely((size_t)(ip+length)<(size_t)(ip))) goto _output_error; /* overflow detection */
+ if ((safeDecode) && unlikely((uptrval)(op)+length<(uptrval)(op))) goto _output_error; /* overflow detection */
+ if ((safeDecode) && unlikely((uptrval)(ip)+length<(uptrval)(ip))) goto _output_error; /* overflow detection */
}
/* copy literals */
@@ -1178,7 +1180,7 @@ FORCE_INLINE int LZ4_decompress_generic(
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 */
+ if ((safeDecode) && unlikely((uptrval)(op)+length<(uptrval)op)) goto _output_error; /* overflow detection */
}
length += MINMATCH;