std.hash.Wyhash: fix dangling stack pointer

Closes #23895.
This commit is contained in:
Marc Tiehuis 2025-05-16 19:27:21 +12:00 committed by Alex Rønne Petersen
parent cc1475c91d
commit 224e39316f

View file

@ -73,8 +73,8 @@ pub const Wyhash = struct {
newSelf.smallKey(input);
} else {
var offset: usize = 0;
var scratch: [16]u8 = undefined;
if (self.buf_len < 16) {
var scratch: [16]u8 = undefined;
const rem = 16 - self.buf_len;
@memcpy(scratch[0..rem], self.buf[self.buf.len - rem ..][0..rem]);
@memcpy(scratch[rem..][0..self.buf_len], self.buf[0..self.buf_len]);