mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-26 09:01:35 +01:00
Tighten the Huffman n_bits invariant.
This commit is contained in:
1 parent
30ce73ad26
commit
848d66ffdf
4 files changed
+23
-14
No files matched your search
@@ -18,7 +18,7 @@ pri func flate_decoder.decode_huffman_slow?(dst writer1, src reader1)() {
|
||||
// decode_huffman_*.puffs files as small as possible, while retaining both
|
||||
// correctness and performance.
|
||||
|
||||
if this.n_bits >= 8 {
|
||||
if (this.n_bits >= 8) or ((this.bits >> this.n_bits) != 0) {
|
||||
return error "internal error: inconsistent n_bits"
|
||||
}
|
||||
|
||||
@@ -254,12 +254,12 @@ pri func flate_decoder.decode_huffman_slow?(dst writer1, src reader1)() {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: "assert n_bits < 8"?
|
||||
// TODO: "assert n_bits < 8"? What about (bits >> n_bits)?
|
||||
|
||||
this.bits = bits
|
||||
this.n_bits = n_bits
|
||||
|
||||
if this.n_bits >= 8 {
|
||||
if (this.n_bits >= 8) or ((this.bits >> this.n_bits) != 0) {
|
||||
return error "internal error: inconsistent n_bits"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user