1
0
mirror of https://github.com/Mrs4s/MiraiGo.git synced 2025-06-18 13:35:03 +08:00

修复越界 (#314)

* 修复utils.B2S越界
This commit is contained in:
icarus-ai 2023-02-08 11:35:29 +08:00 committed by GitHub
parent 91f9576e48
commit d9cc29c678
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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.