mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-19 08:38:14 +01:00
For "x shift y", check that y < (x's bit-size)
This commit is contained in:
1 parent
65c2f4971f
commit
705a84723a
6 files changed
+65
-36
No files matched your search
@@ -242,7 +242,7 @@ pri func decoder.decode_uncompressed?(dst base.io_writer, src base.io_reader) {
|
||||
// TODO: make this "if" into a function invariant?
|
||||
//
|
||||
// Ditto for decode_huffman_slow and decode_huffman_fast.
|
||||
if (this.n_bits >= 8) or ((this.bits >> this.n_bits) != 0) {
|
||||
if (this.n_bits >= 8) or ((this.bits >> (this.n_bits & 7)) != 0) {
|
||||
return "?internal error: inconsistent n_bits"
|
||||
}
|
||||
this.n_bits = 0
|
||||
|
||||
@@ -34,7 +34,7 @@ pri func decoder.decode_huffman_fast!(dst base.io_writer, src base.io_reader) ba
|
||||
var hlen base.u32[..0x7FFF]
|
||||
var hdist base.u32
|
||||
|
||||
if (this.n_bits >= 8) or ((this.bits >> this.n_bits) != 0) {
|
||||
if (this.n_bits >= 8) or ((this.bits >> (this.n_bits & 7)) != 0) {
|
||||
return "?internal error: inconsistent n_bits"
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ pri func decoder.decode_huffman_slow?(dst base.io_writer, src base.io_reader) {
|
||||
// decode_huffman_*.wuffs files as small as possible, while retaining both
|
||||
// correctness and performance.
|
||||
|
||||
if (this.n_bits >= 8) or ((this.bits >> this.n_bits) != 0) {
|
||||
if (this.n_bits >= 8) or ((this.bits >> (this.n_bits & 7)) != 0) {
|
||||
return "?internal error: inconsistent n_bits"
|
||||
}
|
||||
|
||||
@@ -285,7 +285,7 @@ pri func decoder.decode_huffman_slow?(dst base.io_writer, src base.io_reader) {
|
||||
this.bits = bits
|
||||
this.n_bits = n_bits
|
||||
|
||||
if (this.n_bits >= 8) or ((this.bits >> this.n_bits) != 0) {
|
||||
if (this.n_bits >= 8) or ((this.bits >> (this.n_bits & 7)) != 0) {
|
||||
return "?internal error: inconsistent n_bits"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user