@@ -651,8 +651,8 @@ BZIP3_API s32 bz3_decode_block(struct bz3_state * state, u8 * buffer, s32 data_s
651
651
652
652
data_size -= p * 4 + 1 ;
653
653
654
- if (((model & 2 ) && (lzp_size > bz3_decode_block_bound (state -> block_size ) || lzp_size < 0 )) ||
655
- ((model & 4 ) && (rle_size > bz3_decode_block_bound (state -> block_size ) || rle_size < 0 ))) {
654
+ if (((model & 2 ) && (lzp_size > bz3_bound (state -> block_size ) || lzp_size < 0 )) ||
655
+ ((model & 4 ) && (rle_size > bz3_bound (state -> block_size ) || rle_size < 0 ))) {
656
656
state -> last_error = BZ3_ERR_MALFORMED_HEADER ;
657
657
return -1 ;
658
658
}
@@ -698,7 +698,7 @@ BZIP3_API s32 bz3_decode_block(struct bz3_state * state, u8 * buffer, s32 data_s
698
698
699
699
// Undo LZP
700
700
if (model & 2 ) {
701
- size_src = lzp_decompress (b1 , b2 , lzp_size , bz3_decode_block_bound (state -> block_size ), state -> lzp_lut );
701
+ size_src = lzp_decompress (b1 , b2 , lzp_size , bz3_bound (state -> block_size ), state -> lzp_lut );
702
702
if (size_src == -1 ) {
703
703
state -> last_error = BZ3_ERR_CRC ;
704
704
return -1 ;
@@ -868,7 +868,7 @@ BZIP3_API int bz3_decompress(const uint8_t * in, uint8_t * out, size_t in_size,
868
868
struct bz3_state * state = bz3_new (block_size );
869
869
if (!state ) return BZ3_ERR_INIT ;
870
870
871
- u8 * compression_buf = malloc (bz3_decode_block_bound (block_size ));
871
+ u8 * compression_buf = malloc (bz3_bound (block_size ));
872
872
if (!compression_buf ) {
873
873
bz3_free (state );
874
874
return BZ3_ERR_INIT ;
@@ -940,13 +940,3 @@ BZIP3_API size_t bz3_memory_needed(int32_t block_size) {
940
940
total_size += (1 << LZP_DICTIONARY ) * sizeof (int32_t );
941
941
return total_size ;
942
942
}
943
-
944
- BZIP3_API size_t bz3_decode_block_bound (size_t orig_size ) {
945
- // Block may temporarily exceed the `orig_size` due to
946
- // - RLE not being effective (encoded data pre commit 187b3228c73d4f35916ecb5950f18861ddc853ac)
947
- // - LZP not being effective (encoded data pre commit 187b3228c73d4f35916ecb5950f18861ddc853ac)
948
- // - Burrows Wheeler Transform (added bytes if RLE/LZP didn't save enough space)
949
- // - Arithmetic Coding (on added bytes if prior steps failed)
950
- // The 256-byte padding is claimed by the author as sufficient
951
- return orig_size + 256 ;
952
- }
0 commit comments