diff --git a/utils/string.go b/utils/string.go index 8b091d8d..032e1ac3 100644 --- a/utils/string.go +++ b/utils/string.go @@ -50,7 +50,11 @@ func ConvertSubVersionToInt(str string) int32 { // B2S converts byte slice to a string without memory allocation. func B2S(b []byte) string { - return unsafe.String(&b[0], len(b)) + size := len(b) + if size == 0 { + return "" + } + return unsafe.String(&b[0], size) } // S2B converts string to a byte slice without memory allocation.