Update util.go

This commit is contained in:
anim001k 2025-09-26 20:00:15 +02:00 committed by GitHub
parent de6ff36f36
commit c53814c223
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -53,7 +53,8 @@ func memoryCopy(m []byte, offset, size int64) (cpy []byte) {
return nil
}
if len(m) > int(offset) {
// Check that we have enough data in the slice to safely copy the requested range
if len(m) > int(offset) && int(offset+size) <= len(m) {
cpy = make([]byte, size)
copy(cpy, m[offset:offset+size])