]> wimlib.net Git - wimlib/blobdiff - src/lzms-decompress.c
Make create_decompressor() checks of max_block_size consistent
[wimlib] / src / lzms-decompress.c
index f8bfcdb17344b3055d343e7be7615897484d7bfc..7254091449c052442bae510444f93d7f92b9a9d0 100644 (file)
@@ -1012,16 +1012,6 @@ lzms_decompress(const void *compressed_data, size_t compressed_size,
        if (uncompressed_size == 0)
                return 0;
 
-       /* The x86 post-processor requires that the uncompressed length fit into
-        * a signed 32-bit integer.  Also, the position slot table cannot be
-        * searched for a position of INT32_MAX or greater.  */
-       if (uncompressed_size >= INT32_MAX) {
-               LZMS_DEBUG("Uncompressed length too large "
-                          "(got %zu, expected < INT32_MAX)",
-                          uncompressed_size);
-               return -1;
-       }
-
        /* Decode the literals and matches.  */
        if (lzms_decode_items(compressed_data, compressed_size,
                              uncompressed_data, uncompressed_size, ctx))
@@ -1048,6 +1038,12 @@ lzms_create_decompressor(size_t max_block_size, void **ctx_ret)
 {
        struct lzms_decompressor *ctx;
 
+       /* The x86 post-processor requires that the uncompressed length fit into
+        * a signed 32-bit integer.  Also, the position slot table cannot be
+        * searched for a position of INT32_MAX or greater.  */
+       if (max_block_size >= INT32_MAX)
+               return WIMLIB_ERR_INVALID_PARAM;
+
        ctx = ALIGNED_MALLOC(sizeof(struct lzms_decompressor),
                             DECODE_TABLE_ALIGNMENT);
        if (ctx == NULL)