Skip to content

Commit

Permalink
chore: fix "possible misuse of unsafe.Pointer" (#15)
Browse files Browse the repository at this point in the history
See #7

Signed-off-by: spacewander <[email protected]>
  • Loading branch information
spacewander authored Oct 26, 2022
1 parent c20a07e commit c3ca9b9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/utils/string.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import (
func BytesToString(ptr uint64, len uint64) string {
var s string
var sHdr = (*reflect.StringHeader)(unsafe.Pointer(&s))
sHdr.Data = uintptr(unsafe.Pointer(uintptr(ptr)))
sHdr.Data = uintptr(ptr)
sHdr.Len = int(len)
return s
}

func BytesToSlice(ptr uint64, len uint64) []byte {
var s []byte
var sHdr = (*reflect.SliceHeader)(unsafe.Pointer(&s))
sHdr.Data = uintptr(unsafe.Pointer(uintptr(ptr)))
sHdr.Data = uintptr(ptr)
sHdr.Len = int(len)
sHdr.Cap = int(len)
return s
Expand Down

0 comments on commit c3ca9b9

Please sign in to comment.