aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/runtime/runtime.go
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2018-10-29 14:02:47 +0100
committerAyke van Laethem <[email protected]>2018-10-29 14:02:47 +0100
commit772c6486ab39ded397f9c830c61865e17df45035 (patch)
tree6f75ed85e7ae111001863023464faca3a88508ee /src/runtime/runtime.go
parentd90d7be8a8f167c3e39292da36f18af1f311b2cf (diff)
downloadtinygo-772c6486ab39ded397f9c830c61865e17df45035.tar.gz
tinygo-772c6486ab39ded397f9c830c61865e17df45035.zip
runtime: correctly copy a zero-length buffer backwards
Fixes: https://github.com/aykevl/tinygo/issues/64
Diffstat (limited to 'src/runtime/runtime.go')
-rw-r--r--src/runtime/runtime.go6
1 files changed, 1 insertions, 5 deletions
diff --git a/src/runtime/runtime.go b/src/runtime/runtime.go
index 209bbf880..d7b8d244a 100644
--- a/src/runtime/runtime.go
+++ b/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
- }
}
}