diff options
author | Yann Collet <cyan@fb.com> | 2017-06-26 18:29:05 (GMT) |
---|---|---|
committer | Yann Collet <cyan@fb.com> | 2017-06-26 18:29:05 (GMT) |
commit | 6ad3a983dbf3a25273e04051d29022c72c469cd5 (patch) | |
tree | c010e4eb8b3811a97d7c23552bdfc957bd30bcb0 /lib/lz4.c | |
parent | 2ef4afeebeadae41a83f4cb5702180f8137c30f6 (diff) | |
download | lz4-6ad3a983dbf3a25273e04051d29022c72c469cd5.zip lz4-6ad3a983dbf3a25273e04051d29022c72c469cd5.tar.gz lz4-6ad3a983dbf3a25273e04051d29022c72c469cd5.tar.bz2 |
fix #369
The bug would make the bt search read one byte in an invalid memory region,
and make a branch decision based on its value.
Impact was small (missed compression opportunity).
It only happens in -BD mode, with extDict-prefix overlapping matches.
The bt match search is supposed to work also in extDict mode.
In which case, the match ptr can point into Dict.
When the match was overlapping Dict<->Prefix,
match[matchLength] would end up outside of Dict, in an invalid memory area.
The correction ensures that in such a case,
match[matchLength] ends up at intended location, inside prefix.
Diffstat (limited to 'lib/lz4.c')
-rw-r--r-- | lib/lz4.c | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -280,10 +280,22 @@ static const int LZ4_minLength = (MFLIMIT+1); /*-************************************ -* Common Utils +* Error detection **************************************/ #define LZ4_STATIC_ASSERT(c) { enum { LZ4_static_assert = 1/(int)(!!(c)) }; } /* use only *after* variable declarations */ +#if defined(LZ4_DEBUG) && (LZ4_DEBUG>=2) +# include <stdio.h> +# define DEBUGLOG(l, ...) { \ + if (l<=LZ4_DEBUG) { \ + fprintf(stderr, __FILE__ ": "); \ + fprintf(stderr, __VA_ARGS__); \ + fprintf(stderr, " \n"); \ + } } +#else +# define DEBUGLOG(l, ...) {} /* disabled */ +#endif + /*-************************************ * Common functions |