mirror of
https://github.com/minio/minio.git
synced 2025-03-30 17:23:42 -04:00
Fix Windows memory leak (#9680)
When running a zoned setup simply uploading will run the system out of memory very fast. Root cause: nFileSystemNameSize is a DWORD and not a pointer. No idea how this didn't crash hard. Furthermore replace poor mans utf16 -> string conversion to support arbitrary output. Fixes #9630
This commit is contained in:
parent
5f6d6c3b70
commit
7d79c723e5
@ -31,10 +31,10 @@ var (
|
|||||||
|
|
||||||
// getFSType returns the filesystem type of the underlying mounted filesystem
|
// getFSType returns the filesystem type of the underlying mounted filesystem
|
||||||
func getFSType(path string) string {
|
func getFSType(path string) string {
|
||||||
var volumeNameSize uint32 = 260
|
volumeNameSize, nFileSystemNameSize := uint32(260), uint32(260)
|
||||||
var nFileSystemNameSize, lpVolumeSerialNumber uint32
|
var lpVolumeSerialNumber uint32
|
||||||
var lpFileSystemFlags, lpMaximumComponentLength uint32
|
var lpFileSystemFlags, lpMaximumComponentLength uint32
|
||||||
var lpFileSystemNameBuffer, volumeName [260]byte
|
var lpFileSystemNameBuffer, volumeName [130]uint16
|
||||||
var ps = syscall.StringToUTF16Ptr(filepath.VolumeName(path))
|
var ps = syscall.StringToUTF16Ptr(filepath.VolumeName(path))
|
||||||
|
|
||||||
// Extract values safely
|
// Extract values safely
|
||||||
@ -56,15 +56,7 @@ func getFSType(path string) string {
|
|||||||
uintptr(unsafe.Pointer(&lpMaximumComponentLength)),
|
uintptr(unsafe.Pointer(&lpMaximumComponentLength)),
|
||||||
uintptr(unsafe.Pointer(&lpFileSystemFlags)),
|
uintptr(unsafe.Pointer(&lpFileSystemFlags)),
|
||||||
uintptr(unsafe.Pointer(&lpFileSystemNameBuffer)),
|
uintptr(unsafe.Pointer(&lpFileSystemNameBuffer)),
|
||||||
uintptr(unsafe.Pointer(&nFileSystemNameSize)), 0)
|
uintptr(nFileSystemNameSize))
|
||||||
var bytes []byte
|
|
||||||
if lpFileSystemNameBuffer[6] == 0 {
|
|
||||||
bytes = []byte{lpFileSystemNameBuffer[0], lpFileSystemNameBuffer[2],
|
|
||||||
lpFileSystemNameBuffer[4]}
|
|
||||||
} else {
|
|
||||||
bytes = []byte{lpFileSystemNameBuffer[0], lpFileSystemNameBuffer[2],
|
|
||||||
lpFileSystemNameBuffer[4], lpFileSystemNameBuffer[6]}
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(bytes)
|
return syscall.UTF16ToString(lpFileSystemNameBuffer[:])
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user