From 2ad8f99790dda7d021202b9d7830d24d80d4e331 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Sat, 1 May 2021 21:56:45 +0200 Subject: [PATCH] ZLIB level 0: LEN/NLEN = i16. --- core/compress/zlib/zlib.odin | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/core/compress/zlib/zlib.odin b/core/compress/zlib/zlib.odin index 5ce1f26ad..252470f7a 100644 --- a/core/compress/zlib/zlib.odin +++ b/core/compress/zlib/zlib.odin @@ -446,7 +446,7 @@ inflate_from_stream_raw :: proc(z: ^Context, allocator := context.allocator) -> final = compress.read_bits_lsb(z, 1); type = compress.read_bits_lsb(z, 2); - // log.debugf("Final: %v | Type: %v\n", final, type); + // fmt.printf("Final: %v | Type: %v\n", final, type); switch type { case 0: @@ -455,9 +455,13 @@ inflate_from_stream_raw :: proc(z: ^Context, allocator := context.allocator) -> // Discard bits until next byte boundary compress.discard_to_next_byte_lsb(z); - uncompressed_len := int(compress.read_bits_lsb(z, 16)); - length_check := int(compress.read_bits_lsb(z, 16)); - if uncompressed_len != ~length_check { + uncompressed_len := i16(compress.read_bits_lsb(z, 16)); + length_check := i16(compress.read_bits_lsb(z, 16)); + + // fmt.printf("LEN: %v, ~LEN: %v, NLEN: %v, ~NLEN: %v\n", uncompressed_len, ~uncompressed_len, length_check, ~length_check); + + + if ~uncompressed_len != length_check { return E_Deflate.Len_Nlen_Mismatch; }