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:
parent
8f04deadc1
commit
f1cf7466c7
@ -40,9 +40,10 @@ func (rb *ringBuffer) Read(p []byte) (n int, err error) {
|
|||||||
n = pLen
|
n = pLen
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < n; i, rb.rIndex = i+1, rb.rIndex+1 {
|
copy(p, rb.buffer[rb.rIndex:rb.rIndex+n])
|
||||||
p[i] = rb.buffer[rb.rIndex]
|
rb.rIndex += n
|
||||||
}
|
|
||||||
|
return n, nil
|
||||||
case rb.rIndex > rb.wIndex:
|
case rb.rIndex > rb.wIndex:
|
||||||
// Read up to min(len(buf) - rIndex, len(p)) bytes
|
// Read up to min(len(buf) - rIndex, len(p)) bytes
|
||||||
n = len(rb.buffer) - rb.rIndex
|
n = len(rb.buffer) - rb.rIndex
|
||||||
@ -50,17 +51,15 @@ func (rb *ringBuffer) Read(p []byte) (n int, err error) {
|
|||||||
n = pLen
|
n = pLen
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < n; i, rb.rIndex = i+1, rb.rIndex+1 {
|
copy(p, rb.buffer[rb.rIndex:rb.rIndex+n])
|
||||||
p[i] = rb.buffer[rb.rIndex]
|
rb.rIndex += n
|
||||||
}
|
|
||||||
|
|
||||||
if rb.rIndex == len(rb.buffer) {
|
if rb.rIndex == len(rb.buffer) {
|
||||||
rb.rIndex = 0
|
rb.rIndex = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return n, nil
|
||||||
default: // rIndex == wIndex
|
default: // rIndex == wIndex
|
||||||
n, err = 0, io.EOF
|
return 0, io.EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
return n, err
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user