Guard against the LZW literal_width changing

This commit is contained in:
Nigel Tao committed 2018-05-13 15:55:24 +10:00
1 parent f10ff8c896
commit e0478b1d91
3 files changed
+11 -4

No files matched your search

+3 -2
View File
@@ -40,7 +40,8 @@ pri func lzw_decoder.decode?(dst base.io_writer, src base.io_reader)() {
// `max`. 4096 means do not save.
var save_code base.u32[..4096] = end_code
var prev_code base.u32[..4095]
var width base.u32[..12] = this.literal_width + 1
var initial_width base.u32[..12] = this.literal_width + 1
var width base.u32[..12] = initial_width
// These variables yield src's bits in Least Significant Bits order.
var bits base.u32
@@ -73,7 +74,7 @@ pri func lzw_decoder.decode?(dst base.io_writer, src base.io_reader)() {
} else if code == clear_code {
save_code = end_code
prev_code = 0
width = this.literal_width + 1
width = initial_width
continue
} else if code == end_code {