base: io_writer.limited_etc_fast now needs len>=1

This commit is contained in:
Nigel Tao committed 2023-11-25 10:50:02 +11:00
1 parent dc269f3f54
commit 8de7f559e0
7 files changed
+43

No files matched your search

+4
View File
@@ -146,6 +146,7 @@ pri func decoder.decode_huffman_bmi2!(dst: base.io_writer, src: base.io_reader)
bits >>= table_entry_n_bits
n_bits ~mod-= table_entry_n_bits
}
assert length >= 1
// Decode a dcode symbol from H-D.
table_entry = this.huffs[1][bits & dmask]
@@ -190,6 +191,7 @@ pri func decoder.decode_huffman_bmi2!(dst: base.io_writer, src: base.io_reader)
// decode_huffman_slow.
while true,
pre args.dst.length() >= 266,
pre length >= 1,
{
// We can therefore prove:
assert (length as base.u64) <= args.dst.length() via "a <= b: a <= c; c <= b"(c: 266)
@@ -227,6 +229,7 @@ pri func decoder.decode_huffman_bmi2!(dst: base.io_writer, src: base.io_reader)
// No need to copy from args.dst.
continue.loop
}
assert length >= 1
if (((dist_minus_1 + 1) as base.u64) > args.dst.history_length()) or
((length as base.u64) > args.dst.length()) or
@@ -237,6 +240,7 @@ pri func decoder.decode_huffman_bmi2!(dst: base.io_writer, src: base.io_reader)
// Once again, redundant but explicit assertions.
assert (dist_minus_1 + 1) >= 1
assert ((dist_minus_1 + 1) as base.u64) <= args.dst.history_length()
assert length >= 1
assert (length as base.u64) <= args.dst.length()
assert ((length + 8) as base.u64) <= args.dst.length()
+4
View File
@@ -201,6 +201,7 @@ pri func decoder.decode_huffman_fast32!(dst: base.io_writer, src: base.io_reader
} else {
assert args.src.length() >= 6
}
assert length >= 1
// Ensure that we have at least 15 bits of input.
if n_bits < 15 {
@@ -295,6 +296,7 @@ pri func decoder.decode_huffman_fast32!(dst: base.io_writer, src: base.io_reader
// decode_huffman_slow.
while true,
pre args.dst.length() >= 266,
pre length >= 1,
{
// We can therefore prove:
assert (length as base.u64) <= args.dst.length() via "a <= b: a <= c; c <= b"(c: 266)
@@ -332,6 +334,7 @@ pri func decoder.decode_huffman_fast32!(dst: base.io_writer, src: base.io_reader
// No need to copy from args.dst.
continue.loop
}
assert length >= 1
if (((dist_minus_1 + 1) as base.u64) > args.dst.history_length()) or
((length as base.u64) > args.dst.length()) or
@@ -342,6 +345,7 @@ pri func decoder.decode_huffman_fast32!(dst: base.io_writer, src: base.io_reader
// Once again, redundant but explicit assertions.
assert (dist_minus_1 + 1) >= 1
assert ((dist_minus_1 + 1) as base.u64) <= args.dst.history_length()
assert length >= 1
assert (length as base.u64) <= args.dst.length()
assert ((length + 8) as base.u64) <= args.dst.length()
+4
View File
@@ -145,6 +145,7 @@ pri func decoder.decode_huffman_fast64!(dst: base.io_writer, src: base.io_reader
bits >>= table_entry_n_bits
n_bits ~mod-= table_entry_n_bits
}
assert length >= 1
// Decode a dcode symbol from H-D.
table_entry = this.huffs[1][bits & dmask]
@@ -189,6 +190,7 @@ pri func decoder.decode_huffman_fast64!(dst: base.io_writer, src: base.io_reader
// decode_huffman_slow.
while true,
pre args.dst.length() >= 266,
pre length >= 1,
{
// We can therefore prove:
assert (length as base.u64) <= args.dst.length() via "a <= b: a <= c; c <= b"(c: 266)
@@ -226,6 +228,7 @@ pri func decoder.decode_huffman_fast64!(dst: base.io_writer, src: base.io_reader
// No need to copy from args.dst.
continue.loop
}
assert length >= 1
if (((dist_minus_1 + 1) as base.u64) > args.dst.history_length()) or
((length as base.u64) > args.dst.length()) or
@@ -236,6 +239,7 @@ pri func decoder.decode_huffman_fast64!(dst: base.io_writer, src: base.io_reader
// Once again, redundant but explicit assertions.
assert (dist_minus_1 + 1) >= 1
assert ((dist_minus_1 + 1) as base.u64) <= args.dst.history_length()
assert length >= 1
assert (length as base.u64) <= args.dst.length()
assert ((length + 8) as base.u64) <= args.dst.length()