summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/yuin/goldmark/util/util_unsafe.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/yuin/goldmark/util/util_unsafe.go')
-rw-r--r--vendor/github.com/yuin/goldmark/util/util_unsafe.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/vendor/github.com/yuin/goldmark/util/util_unsafe.go b/vendor/github.com/yuin/goldmark/util/util_unsafe.go
index beeae29361..d098811044 100644
--- a/vendor/github.com/yuin/goldmark/util/util_unsafe.go
+++ b/vendor/github.com/yuin/goldmark/util/util_unsafe.go
@@ -13,8 +13,11 @@ func BytesToReadOnlyString(b []byte) string {
}
// StringToReadOnlyBytes returns bytes converted from given string.
-func StringToReadOnlyBytes(s string) []byte {
+func StringToReadOnlyBytes(s string) (bs []byte) {
sh := (*reflect.StringHeader)(unsafe.Pointer(&s))
- bh := reflect.SliceHeader{Data: sh.Data, Len: sh.Len, Cap: sh.Len}
- return *(*[]byte)(unsafe.Pointer(&bh))
+ bh := (*reflect.SliceHeader)(unsafe.Pointer(&bs))
+ bh.Data = sh.Data
+ bh.Cap = sh.Len
+ bh.Len = sh.Len
+ return
}