| ... | ... | @@ -226,18 +226,19 @@ pub const Decode = struct { |
| 226 | 226 | try ld.resetState(allocating.allocator, new_props); |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | const expected_unpacked_size = accum.len + unpacked_size; |
| 229 | 230 | const start_count = n_read; |
| 230 | 231 | var range_decoder = try lzma.RangeDecoder.initCounting(reader, &n_read); |
| 231 | 232 | |
| 232 | 233 | while (true) { |
| 233 | | if (accum.len >= unpacked_size) break; |
| 234 | if (accum.len >= expected_unpacked_size) break; |
| 234 | 235 | if (range_decoder.isFinished()) break; |
| 235 | 236 | switch (try ld.process(reader, allocating, accum, &range_decoder, &n_read)) { |
| 236 | 237 | .more => continue, |
| 237 | 238 | .finished => break, |
| 238 | 239 | } |
| 239 | 240 | } |
| 240 | | if (accum.len != unpacked_size) return error.DecompressedSizeMismatch; |
| 241 | if (accum.len != expected_unpacked_size) return error.DecompressedSizeMismatch; |
| 241 | 242 | if (n_read - start_count != packed_size) return error.CompressedSizeMismatch; |
| 242 | 243 | |
| 243 | 244 | return n_read; |