Skip to content

Commit

Permalink
Fix mask alignment
Browse files Browse the repository at this point in the history
Fix incorrect computation of buffer alignment in maskBytes. With this
change, all word operations on the buffer are aligned on word
boundaries.
  • Loading branch information
garyburd committed Nov 2, 2016
1 parent 2aff870 commit 343fff4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mask.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 343fff4

Please sign in to comment.