diff options
author | Yann Collet <cyan@fb.com> | 2017-10-19 23:47:25 (GMT) |
---|---|---|
committer | Yann Collet <cyan@fb.com> | 2017-10-19 23:47:25 (GMT) |
commit | 6cec68de39345ac754d75b5ed694b7e3e28cc3ec (patch) | |
tree | c2b05d264635b77159fccad6f9b7150e451e4e66 | |
parent | ac2ad52257defcc944471d0fdf3c6d68abebe904 (diff) | |
download | lz4-6cec68de39345ac754d75b5ed694b7e3e28cc3ec.zip lz4-6cec68de39345ac754d75b5ed694b7e3e28cc3ec.tar.gz lz4-6cec68de39345ac754d75b5ed694b7e3e28cc3ec.tar.bz2 |
added assert
-rw-r--r-- | lib/lz4.c | 8 | ||||
-rw-r--r-- | lib/lz4opt.h | 2 |
2 files changed, 9 insertions, 1 deletions
@@ -289,6 +289,14 @@ static const int LZ4_minLength = (MFLIMIT+1); /*-************************************ * Error detection **************************************/ +#if defined(LZ4_DEBUG) && (LZ4_DEBUG>=1) +# include <assert.h> +#else +# ifndef assert +# define assert(condition) ((void)0) +# endif +#endif + #define LZ4_STATIC_ASSERT(c) { enum { LZ4_static_assert = 1/(int)(!!(c)) }; } /* use only *after* variable declarations */ #if defined(LZ4_DEBUG) && (LZ4_DEBUG>=2) diff --git a/lib/lz4opt.h b/lib/lz4opt.h index e6a748c..69c48dc 100644 --- a/lib/lz4opt.h +++ b/lib/lz4opt.h @@ -262,7 +262,7 @@ static int LZ4HC_compress_optimal ( SET_PRICE(mlen, mlen, matches[matchNb].off, 0, cost); /* updates last_match_pos and opt[pos] */ } } } - if (last_match_pos < MINMATCH) { ip++; continue; } /* note : on clang at least, this test improves performance */ + assert(last_match_pos >= MINMATCH); /* check further positions */ opt[0].mlen = opt[1].mlen = 1; |