1
0
mirror of https://github.com/taigrr/gopher-os synced 2025-01-18 04:43:13 -08:00

Revert "kfmt: fix bug where calls to copy() resulted in garbage being copied"

This reverts commit 8f04deadc1f1620dbd0aaea07f04a6c7f82f58c0.

The actual issue was triggered by a memory corruption due to the fact
that the exception handling gate code did not preserve XMM regs.
This commit is contained in:
Achilleas Anagnostopoulos 2018-04-27 19:26:08 +01:00
parent 8f04deadc1
commit f1cf7466c7

View File

@ -40,9 +40,10 @@ func (rb *ringBuffer) Read(p []byte) (n int, err error) {
n = pLen
}
for i := 0; i < n; i, rb.rIndex = i+1, rb.rIndex+1 {
p[i] = rb.buffer[rb.rIndex]
}
copy(p, rb.buffer[rb.rIndex:rb.rIndex+n])
rb.rIndex += n
return n, nil
case rb.rIndex > rb.wIndex:
// Read up to min(len(buf) - rIndex, len(p)) bytes
n = len(rb.buffer) - rb.rIndex
@ -50,17 +51,15 @@ func (rb *ringBuffer) Read(p []byte) (n int, err error) {
n = pLen
}
for i := 0; i < n; i, rb.rIndex = i+1, rb.rIndex+1 {
p[i] = rb.buffer[rb.rIndex]
}
copy(p, rb.buffer[rb.rIndex:rb.rIndex+n])
rb.rIndex += n
if rb.rIndex == len(rb.buffer) {
rb.rIndex = 0
}
return n, nil
default: // rIndex == wIndex
n, err = 0, io.EOF
return 0, io.EOF
}
return n, err
}