From d9cc29c678cb1e88e03c962e2fc413c11953fcff Mon Sep 17 00:00:00 2001 From: icarus-ai <82353054+icarus-ai@users.noreply.github.com> Date: Wed, 8 Feb 2023 11:35:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=B6=8A=E7=95=8C=20(#314)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 修复utils.B2S越界 --- utils/string.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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.