diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2025-08-26 20:49:37 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2025-08-26 21:00:58 -0700 |
| commit | 980445f08bfee496f4e784b05653e1698addaac8 (patch) | |
| tree | b6073503e8f18cd04f8df385023ef8c058fa8f19 /lib/std | |
| parent | 722e066173f5235b1dd1b341acb5cb1e79002ed7 (diff) | |
| download | zig-980445f08bfee496f4e784b05653e1698addaac8.tar.gz zig-980445f08bfee496f4e784b05653e1698addaac8.zip | |
std.compress.lzma: fix unpacked size checking logic
Diffstat (limited to 'lib/std')
| -rw-r--r-- | lib/std/compress/lzma2.zig | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/std/compress/lzma2.zig b/lib/std/compress/lzma2.zig index e99b2fe091..46e06bedab 100644 --- a/lib/std/compress/lzma2.zig +++ b/lib/std/compress/lzma2.zig @@ -226,18 +226,19 @@ pub const Decode = struct { try ld.resetState(allocating.allocator, new_props); } + const expected_unpacked_size = accum.len + unpacked_size; const start_count = n_read; var range_decoder = try lzma.RangeDecoder.initCounting(reader, &n_read); while (true) { - if (accum.len >= unpacked_size) break; + if (accum.len >= expected_unpacked_size) break; if (range_decoder.isFinished()) break; switch (try ld.process(reader, allocating, accum, &range_decoder, &n_read)) { .more => continue, .finished => break, } } - if (accum.len != unpacked_size) return error.DecompressedSizeMismatch; + if (accum.len != expected_unpacked_size) return error.DecompressedSizeMismatch; if (n_read - start_count != packed_size) return error.CompressedSizeMismatch; return n_read; |
