Skip to content

Commit

Permalink
fix panic
Browse files Browse the repository at this point in the history
Signed-off-by: lhy1024 <[email protected]>
  • Loading branch information
lhy1024 committed Jul 30, 2024
1 parent 6909d2a commit ffd44d9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/keyvisual/region/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@ import (

// String converts slice of bytes to string without copy.
func String(b []byte) string {
if len(b) == 0 {
return ""
}
return unsafe.String(&b[0], len(b)) // #nosec
}

// Bytes converts a string into a byte slice. Need to make sure that the byte slice is not modified.
func Bytes(s string) []byte {
if len(s) == 0 {
return nil
}
return unsafe.Slice(unsafe.StringData(s), len(s)) // #nosec
}

0 comments on commit ffd44d9

Please sign in to comment.