Browse Source

runtime: correctly copy a zero-length buffer backwards

Fixes:
https://github.com/aykevl/tinygo/issues/64
pull/62/head
Ayke van Laethem 6 years ago
parent
commit
772c6486ab
No known key found for this signature in database GPG Key ID: E97FF5335DFDFDED
  1. 6
      src/runtime/runtime.go

6
src/runtime/runtime.go

@ -54,13 +54,9 @@ func memmove(dst, src unsafe.Pointer, size uintptr) {
return
}
// Copy backwards.
i := size
for {
for i := size; i != 0; {
i--
*(*uint8)(unsafe.Pointer(uintptr(dst) + i)) = *(*uint8)(unsafe.Pointer(uintptr(src) + i))
if i == 0 {
break
}
}
}

Loading…
Cancel
Save