Commit 455ea58872

Marc Tiehuis <marc@tiehu.is>
2025-05-16 09:27:21
std.hash.Wyhash: fix dangling stack pointer
Closes #23895.
1 parent 925cc08
Changed files (1)
lib
std
lib/std/hash/wyhash.zig
@@ -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]);