From 343fff4c5ceeb405e29e80dcd5d4d1598d4c7a27 Mon Sep 17 00:00:00 2001 From: Gary Burd Date: Wed, 2 Nov 2016 09:16:35 -0700 Subject: [PATCH] Fix mask alignment Fix incorrect computation of buffer alignment in maskBytes. With this change, all word operations on the buffer are aligned on word boundaries. --- mask.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mask.go b/mask.go index 68861fc..6758a2c 100644 --- a/mask.go +++ b/mask.go @@ -28,7 +28,7 @@ func maskBytes(key [4]byte, pos int, b []byte) int { } // Mask one byte at a time to word boundary. - if n := int(uintptr(unsafe.Pointer(&b))) % wordSize; n != 0 { + if n := int(uintptr(unsafe.Pointer(&b[0]))) % wordSize; n != 0 { n = wordSize - n for i := range b[:n] { b[i] ^= key[pos&3]