]> wimlib.net Git - wimlib/blobdiff - src/lzms-compress.c
inode_fixup.c: Don't check ADS count when all have zero hashes
[wimlib] / src / lzms-compress.c
index 3354bd9f62e81fbd70ec1421f4a413f1a96aeff7..2f87fd4320bcc7ebf2baa204724c4884d0aeb330 100644 (file)
@@ -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(&params->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;