Skip to content

Commit

Permalink
compiler-rt: fix overflow when memcpy CopyType size is < 32
Browse files Browse the repository at this point in the history
  • Loading branch information
dweiller committed May 11, 2024
1 parent 764d574 commit 8121f4d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/compiler_rt/memcpy.zig
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ pub fn memcpy(noalias dest: ?[*]u8, noalias src: ?[*]const u8, len: usize) callc
return dest;
}

inline for (5..std.math.log2(2 * size) + 1) |p| {
const limit = 1 << p;
if (len <= limit) {
memcpy_range2(limit / 2, dest.?, src.?, len);
return dest;
if (5 < std.math.log2(2 * size)) {
inline for (5..std.math.log2(2 * size) + 1) |p| {
const limit = 1 << p;
if (len <= limit) {
memcpy_range2(limit / 2, dest.?, src.?, len);
return dest;
}
}
}

Expand Down

0 comments on commit 8121f4d

Please sign in to comment.