Skip to content

Commit 68f590d

Browse files
committed
std.compress.xz: fix 32-bit targets
1 parent 0339c57 commit 68f590d

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

lib/std/compress/xz/Decompress.zig

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,9 @@ fn readBlock(input: *Reader, allocating: *Writer.Allocating) !void {
259259

260260
// Block Padding
261261
const block_counter = header_size + packed_bytes_read;
262-
const padding = (4 - (block_counter % 4)) % 4;
263-
for (0..padding) |_| {
264-
if (try input.takeByte() != 0) return error.CorruptInput;
262+
const padding = try input.take(@intCast((4 - (block_counter % 4)) % 4));
263+
for (padding) |byte| {
264+
if (byte != 0) return error.CorruptInput;
265265
}
266266
}
267267

@@ -279,14 +279,13 @@ fn finish(d: *Decompress) !void {
279279
if (record_count != d.block_count)
280280
return error.CorruptInput;
281281

282-
for (0..record_count) |_| {
282+
for (0..@intCast(record_count)) |_| {
283283
// TODO: validate records
284284
_ = try countLeb128(input, u64, &input_counter, &checksum);
285285
_ = try countLeb128(input, u64, &input_counter, &checksum);
286286
}
287287

288-
const padding_len = (4 - (input_counter % 4)) % 4;
289-
const padding = try input.take(padding_len);
288+
const padding = try input.take(@intCast((4 - (input_counter % 4)) % 4));
290289
for (padding) |byte| {
291290
if (byte != 0) return error.CorruptInput;
292291
}

0 commit comments

Comments
 (0)