lib/fs: properly handle the case when data=nil is passed to mUnmap

This commit is contained in:
Aliaksandr Valialkin 2024-02-29 17:26:07 +02:00
parent c75bfd5b07
commit e959f54351
No known key found for this signature in database
GPG key ID: 52C003EE2BCDB9EB

View file

@ -101,7 +101,7 @@ func mmap(fd int, length int) ([]byte, error) {
func mUnmap(data []byte) error { func mUnmap(data []byte) error {
// flush is not needed, since we perform only reading operation. // flush is not needed, since we perform only reading operation.
// In case of write, additional call FlushViewOfFile must be performed. // In case of write, additional call FlushViewOfFile must be performed.
addr := uintptr(unsafe.Pointer(&data[0])) addr := uintptr(unsafe.Pointer(unsafe.SliceData(data)))
mmapByAddrLock.Lock() mmapByAddrLock.Lock()
h, ok := mmapByAddr[addr] h, ok := mmapByAddr[addr]