Bounds check "if" statements.

This commit is contained in:
Nigel Tao committed 2017-06-06 19:01:48 +10:00
1 parent f686adc3c0
commit 84bf437013
4 files changed
+149 -5

No files matched your search

+7 -3
View File
@@ -8,9 +8,8 @@ pub struct lzw_decoder?(
pub func lzw_decoder.decode?(dst ptr buf1, src ptr buf1, src_final bool)() {
var bits u32
var n_bits u32
// TODO: set clear_code, end_code, etc.
var clear_code u32 = (1 as u32) << this.literal_width
// TODO: set end_code.
var width u32[..12] = this.literal_width + 1
// TODO: implement.
@@ -31,6 +30,11 @@ pub func lzw_decoder.decode?(dst ptr buf1, src ptr buf1, src_final bool)() {
bits >>= width
n_bits -= width
// TODO: s/bits/code/
if bits < clear_code {
break
}
// TODO: implement.
break
}