From 548c9aef8225deae08f62a92d53166fd7e2348cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Thu, 15 Jan 2015 16:43:08 +0100 Subject: [PATCH] Allocate memory for hash values coming from JIT --- vm/vm_jit.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vm/vm_jit.go b/vm/vm_jit.go index 4ce3531958..55c304b250 100644 --- a/vm/vm_jit.go +++ b/vm/vm_jit.go @@ -61,13 +61,15 @@ func hash2llvm(h []byte) i256 { return m } -func llvm2hash(m *i256) []byte { //TODO: It should copy data +func llvm2hash(m *i256) []byte { + hash := make([]byte, len(m)) hdr := reflect.SliceHeader{ Data: uintptr(unsafe.Pointer(m)), Len: int(len(m)), Cap: int(len(m)), } - return *(*[]byte)(unsafe.Pointer(&hdr)) + copy(hash, *(*[]byte)(unsafe.Pointer(&hdr))) + return hash } func bswap(m *i256) *i256 {