#1911·gopsutil

Leak in PartitionsWithContext

Author: StefanoBalzarottiNozomiCreated Sep 3, 2025Updated Oct 29, 2025

Describe the bug If you mount a directory as volume on a long path, the code gets stuck in an finite loop, causing also a memory leak by appending error to the list of warning.

To Reproduce

go
for {            
    mounts, err := getVolumePaths(volNameBuf)
	// Here the code returns an error, and it will never succeed because size of volNameBuf is not enough
	if err != nil {
		warnings.Add(fmt.Errorf("failed to find paths for volume %s", windows.UTF16ToString(volNameBuf))) // array append
		continue // back to where we started
	}

Expected behavior The code does't keak

Environment (please complete the following information):

  • Windows: [Windows 11 Enterprise]