Skip to content

Commit b4ce062

Browse files
committed
Only read huffman code when it exists.
1 parent e8df76f commit b4ce062

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

arch/INFLATE.LUA

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -301,20 +301,23 @@ function inflate(r, w, z)
301301

302302
b, x = e[1], e[2]
303303
a = x > 0 and bs.r(x) or 0
304-
l, ds = b + a, rh(d)
305-
de = dix[ds + 1]
306-
db, dx = de[1], de[2]
307-
da = dx > 0 and bs.r(dx) or 0
308-
dv = db + da
309-
310-
if dv <= 0 or dv > op then
311-
print("!Distance", dv, Z, op) os.exit(1)
312-
end
304+
l = b + a
305+
if d.max > 0 and #d.tab > 0 then
306+
ds = rh(d)
307+
de = dix[ds + 1]
308+
db, dx = de[1], de[2]
309+
da = dx > 0 and bs.r(dx) or 0
310+
dv = db + da
311+
312+
if dv <= 0 or dv > op then
313+
print("!Distance", dv, Z, op) os.exit(1)
314+
end
313315

314-
-- Read from window history
315-
for _ = 1, l do
316-
local p = (wp - dv) % Z
317-
ab(sw[p] or 0)
316+
-- Read from window history
317+
for _ = 1, l do
318+
local p = (wp - dv) % Z
319+
ab(sw[p] or 0)
320+
end
318321
end
319322
end
320323
end

0 commit comments

Comments
 (0)