X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Flzms-compress.c;h=2f87fd4320bcc7ebf2baa204724c4884d0aeb330;hb=ccdd5a74123ebf14353a9569bf014fb2e7774d1e;hp=3354bd9f62e81fbd70ec1421f4a413f1a96aeff7;hpb=e9d97e3c9151d137a40d73f6b637783ebaceafd0;p=wimlib diff --git a/src/lzms-compress.c b/src/lzms-compress.c index 3354bd9f..2f87fd43 100644 --- a/src/lzms-compress.c +++ b/src/lzms-compress.c @@ -1168,7 +1168,9 @@ lzms_free_compressor(void *_ctx) } static const struct wimlib_lzms_compressor_params lzms_default = { - .hdr = sizeof(struct wimlib_lzms_compressor_params), + .hdr = { + .size = sizeof(struct wimlib_lzms_compressor_params), + }, .min_match_length = 2, .max_match_length = UINT32_MAX, .nice_match_length = 32, @@ -1177,6 +1179,9 @@ static const struct wimlib_lzms_compressor_params lzms_default = { .optim_array_length = 1024, }; +static bool +lzms_params_valid(const struct wimlib_compressor_params_header *); + static const struct wimlib_lzms_compressor_params * lzms_get_params(const struct wimlib_compressor_params_header *_params) { @@ -1186,6 +1191,8 @@ lzms_get_params(const struct wimlib_compressor_params_header *_params) if (params == NULL) params = &lzms_default; + LZMS_ASSERT(lzms_params_valid(¶ms->hdr)); + return params; } @@ -1219,7 +1226,7 @@ lzms_create_compressor(size_t max_block_size, if (!lz_sarray_init(&ctx->lz_sarray, max_block_size, params->min_match_length, - params->max_match_length, + min(params->max_match_length, LZ_SARRAY_LEN_MAX), params->max_search_depth, params->max_matches_per_pos)) goto oom;