mirror of
https://git.tukaani.org/xz.git
synced 2024-04-04 12:36:23 +02:00
liblzma: Creates IS_ENC_DICT_SIZE_VALID() macro.
This creates an internal liblzma macro to test if the dictionary size is valid for encoding.
This commit is contained in:
parent
c247d06e1f
commit
d0f33d672a
2 changed files with 9 additions and 3 deletions
|
@ -196,9 +196,7 @@ lz_encoder_prepare(lzma_mf *mf, const lzma_allocator *allocator,
|
|||
// For now, the dictionary size is limited to 1.5 GiB. This may grow
|
||||
// in the future if needed, but it needs a little more work than just
|
||||
// changing this check.
|
||||
if (lz_options->dict_size < LZMA_DICT_SIZE_MIN
|
||||
|| lz_options->dict_size
|
||||
> (UINT32_C(1) << 30) + (UINT32_C(1) << 29)
|
||||
if (!IS_ENC_DICT_SIZE_VALID(lz_options->dict_size)
|
||||
|| lz_options->nice_len > lz_options->match_len_max)
|
||||
return true;
|
||||
|
||||
|
|
|
@ -17,6 +17,14 @@
|
|||
#include "common.h"
|
||||
|
||||
|
||||
// For now, the dictionary size is limited to 1.5 GiB. This may grow
|
||||
// in the future if needed, but it needs a little more work than just
|
||||
// changing this check.
|
||||
#define IS_ENC_DICT_SIZE_VALID(size) \
|
||||
((size) >= LZMA_DICT_SIZE_MIN \
|
||||
&& (size) <= (UINT32_C(1) << 30) + (UINT32_C(1) << 29))
|
||||
|
||||
|
||||
/// A table of these is used by the LZ-based encoder to hold
|
||||
/// the length-distance pairs found by the match finder.
|
||||
typedef struct {
|
||||
|
|
Loading…
Reference in a new issue