Skip to content

Commit

Permalink
fix sliceheader use
Browse files Browse the repository at this point in the history
  • Loading branch information
CAFxX committed May 15, 2023
1 parent 098ea3f commit 79fca40
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions launcher/main.go
Expand Up @@ -110,11 +110,9 @@ func str2slice(s string) (b []byte) {
// TODO: when we bump to go1.20 use unsafe.StringData and unsafe.Slice instead.
shdr := (*reflect.StringHeader)(unsafe.Pointer(&s))
bhdr := (*reflect.SliceHeader)(unsafe.Pointer(&b))
*bhdr = reflect.SliceHeader{
Data: shdr.Data,
Len: shdr.Len,
Cap: shdr.Len,
}
bhdr.Data = shdr.Data
bhdr.Len = shdr.Len
bhdr.Cap = shdr.Len
runtime.KeepAlive(s)
return
}
Expand Down

0 comments on commit 79fca40

Please sign in to comment.