std.crypto.tls.Client: fix @memcpy crash in limitedOverlapCopy

Resolves: #15928
This commit is contained in:
mlugg 2023-06-12 22:00:56 +01:00 committed by Andrew Kelley
parent 028f2ed30f
commit 9e61ba19e9

View File

@ -1256,10 +1256,8 @@ fn limitedOverlapCopy(frag: []u8, in: usize) void {
// A single, non-overlapping memcpy suffices.
@memcpy(frag[0..first.len], first);
} else {
// Need two memcpy calls because one alone would overlap.
@memcpy(frag[0..in], first[0..in]);
const leftover = first.len - in;
@memcpy(frag[in..][0..leftover], first[in..][0..leftover]);
// One memcpy call would overlap, so just do this instead.
std.mem.copyForwards(u8, frag, first);
}
}